The HttpServletRequest.getReader doesn't correctly read large entity and returns more data than expected. This happens only with version 8.5.8 (working fine on 8.5.6). I was able to reproduce this with a really simple web app where the issue is occurring for entity larger that 12288 characters. @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException{ StringBuilder builder = new StringBuilder(); try(BufferedReader reader = req.getReader()){ String line; while((line = reader.readLine()) != null){ builder.append(line); } } resp.getWriter().println(req.getContentLength() + " " + builder.length()); resp.getWriter().println(builder); } Then I use this command and I'm able to compare input and parsed data: cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 12289 > input && curl -X POST http://localhost:8080/example -d @input > output
Hi, I was not able to reproduce the issue with the provided example. I received: - input with size 12289 - output with size 12302. The output contains two rows: - the first one contains information for the input and output size: 12289 12289 - the second one contains the input that was sent. If I remove the first line then the both files are identical. Regards, Violeta
Created attachment 34466 [details] server configuration Here is what I get: -rw-r--r-- 1 cguillaume cguillaume 12289 Nov 22 10:30 input -rw-r--r-- 1 cguillaume cguillaume 21302 Nov 22 10:30 output First line: 12289 21289 It seems to happen only when using the apr connector. I attached my server.xml. The apr version I'm using is: INFO: Loaded APR based Apache Tomcat Native library 1.2.10 using APR version 1.5.2.
Thanks, I reproduced the issue. I'll update the issue with my findings later. Regards, Violeta
Hi, The issue was the following: In some cases the buffer used for the request data needs to be expanded. The read position after the expansion was not returned to the correct one. This has been fixed in - 9.0.x for 9.0.0.M14 onwards and - 8.5.x for 8.5.9 onwards Regard, Violeta