Project: Tomcat
Bug 40306 mod_jk, POST request bodies are not restored on successful login when using mod_jk
Reported: 2006-08-23 19:48:03 | Status: resolved fixed

After the FormAuthenticator intercepts a POST request to a protected resource, the original request is not properly restored upon successful login when using mod_jk. When connectiong to tomcat directly (8080), the POST request is restored as expected. I've tested this with mod_jk 1.2.15 and 1.2.18. It seems the problem is that the orginal request is not saved properly. I (think) I've narrowed down the issue in FormAuthenticator.java. body.toString() was returning null. (The buffer was null) so it looks like the root of the problem is that nothing is read from the input stream. During testing I reverted to the old way of adding the request parameters (saved.addParameter()) to see if they were indeed there and it worked. I also tried, InputStream is = new BufferedInputStream(request.getInputStream()); which didn't work.. from FormAuthenticator.java: protected void saveRequest(Request request, Session session) throws IOException { ... if ("POST".equalsIgnoreCase(request.getMethod())) { ByteChunk body = new ByteChunk(); body.setLimit(request.getConnector().getMaxSavePostSize()); byte[] buffer = new byte[4096]; int bytesRead; InputStream is = request.getInputStream(); while ( (bytesRead = is.read(buffer) ) >= 0) { body.append(buffer, 0, bytesRead); } saved.setBody(body); } ... }

Files changed in fix:
java/org/apache/coyote/ajp/AjpAprProcessor.java java/org/apache/jk/core/MsgContext.java