DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=40771>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=40771 Summary: Can't read POST data from within a filter or valve Product: Tomcat 5 Version: 5.5.17 Platform: All OS/Version: Windows XP Status: NEW Severity: minor Priority: P4 Component: Connector:Coyote AssignedTo: tomcat-dev@jakarta.apache.org ReportedBy: [EMAIL PROTECTED] I was attempting to create a Filter or Valve that could be placed in front of an Axis web service that would handle security according to the WS-Security specification. That turned out to be a rabbit trail, but I did find and fix a bug that I discovered along the way. I ran into problems reading POST data (the web service request) from the org.apache.catalina.connector.Request object exposed in the Filter/Valve interfaces. This is a chunk of code in a prototype Valve that didn't work: private ByteChunk getPOSTBody(Request request) throws IOException { ByteChunk retval = new ByteChunk(request.getContentLength()); ByteChunk body = new ByteChunk(request.getContentLength()); int bytesRead; do { bytesRead = request.getCoyoteRequest().doRead(body); retval.append(body); } while (bytesRead >= 0) ; //puts the data back into the pipe. request.getCoyoteRequest().action (ActionCode.ACTION_REQ_SET_BODY_REPLAY, retval); return retval; } This code works as designed, however the problem occurs later on when Axis attempted to parse the web service request. I don't remember the exact Axis error, but I was able to track the problem down to a bug in the org.apache.coyote.http11.filters.SavedRequestInputFilter class. The doRead method was not properly implemented to return a -1 when appropriate. Here is my modified version of the doRead method: public int doRead(ByteChunk chunk, org.apache.coyote.Request request) throws IOException { int writeLength = 0; if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) { writeLength = chunk.getLimit(); } else { writeLength = input.getLength(); } if(input.getOffset()>= input.getEnd()) return -1; input.substract(chunk.getBuffer(), 0, writeLength); chunk.setOffset(0); chunk.setEnd(writeLength); return writeLength; } This bug won't show up unless someone tries to use a filter/valve to do something with web services. That's not too likely because that's what we have SOAPHandlers for. -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]