reading POST body fails on 6.0.16, works on 6.0.14
Hello All, I have a very simple doPost method that reads the body of a POST request. Seems to work fine on 6.0.14 but consistently fails to read the body correctly in 6.0.16. Can someone help me with what's wrong here? Thanks! -- john protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // read POST body StringBuffer sb = new StringBuffer(); try { BufferedReader reader = request.getReader(); String inputLine; while ((inputLine = reader.readLine()) != null) { sb.append(inputLine); } } catch (IOException e) { throw new IllegalStateException(Error reading request body); } String content = sb.toString(); log.debug(read +content.length()+ characters from POST body); if (content.length() != request.getContentLength()) { log.warn(Expected content length of +request.getContentLength()+ but only read +content.length()+ characters); } //write out read content to file PrintStream os = new PrintStream(new FileOutputStream(/tmp/post_body.txt)); os.println(content); os.close(); PrintWriter out = response.getWriter(); response.setContentType(text/plain); out.println(Content Type: + request.getContentType()); out.println(POST body contained + request.getContentLength() + characters); out.println(read + content.length() + characters from POST body); out.flush(); out.close(); } - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: reading POST body fails on 6.0.16, works on 6.0.14
From: John Cartwright [mailto:[EMAIL PROTECTED] Subject: reading POST body fails on 6.0.16, works on 6.0.14 Seems to work fine on 6.0.14 but consistently fails to read the body correctly in 6.0.16. So what does it do? You've got all those print statements in your code - what do they show on the two Tomcat versions? Is there anything in the logs? - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reading POST body fails on 6.0.16, works on 6.0.14
yes, its a bug, and will be fixed in 6.0.17, I think its bug 44494 https://issues.apache.org/bugzilla/show_bug.cgi?id=44494 Filip John Cartwright wrote: Hello All, I have a very simple doPost method that reads the body of a POST request. Seems to work fine on 6.0.14 but consistently fails to read the body correctly in 6.0.16. Can someone help me with what's wrong here? Thanks! -- john protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // read POST body StringBuffer sb = new StringBuffer(); try { BufferedReader reader = request.getReader(); String inputLine; while ((inputLine = reader.readLine()) != null) { sb.append(inputLine); } } catch (IOException e) { throw new IllegalStateException(Error reading request body); } String content = sb.toString(); log.debug(read +content.length()+ characters from POST body); if (content.length() != request.getContentLength()) { log.warn(Expected content length of +request.getContentLength()+ but only read +content.length()+ characters); } //write out read content to file PrintStream os = new PrintStream(new FileOutputStream(/tmp/post_body.txt)); os.println(content); os.close(); PrintWriter out = response.getWriter(); response.setContentType(text/plain); out.println(Content Type: + request.getContentType()); out.println(POST body contained + request.getContentLength() + characters); out.println(read + content.length() + characters from POST body); out.flush(); out.close(); } - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reading POST body fails on 6.0.16, works on 6.0.14
John Cartwright wrote: Hello All, I have a very simple doPost method that reads the body of a POST request. Seems to work fine on 6.0.14 but consistently fails to read the body correctly in 6.0.16. Can someone help me with what's wrong here? https://issues.apache.org/bugzilla/show_bug.cgi?id=44494 Mark - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]