Bug 57485 - mod_jk passed the incomplete chunked transferred request body to tomcat
Summary: mod_jk passed the incomplete chunked transferred request body to tomcat
Alias: None
Product: Tomcat Connectors
Classification: Unclassified
Component: mod_jk (show other bugs)
Version: 1.2.40
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on: 57492
Blocks: 47714
  Show dependency tree
Reported: 2015-01-23 05:15 UTC by charleschung.cn
Modified: 2016-09-22 14:14 UTC (History)
2 users (show)

packet capture (2.88 KB, application/octet-stream)
2015-01-23 05:15 UTC, charleschung.cn

Note You need to log in before you can comment on or make changes to this bug.
Description charleschung.cn 2015-01-23 05:15:43 UTC
Created attachment 32392 [details]
packet capture

I'm using mod_jk to connect apache to tomcat,
When I send the following tcp packets(to simulate incomplete chunked body) and close the socket,strangely my servlet did received the partial body as complete,packet capture shows that mod_jk decoded the chunked body and passed the incomplete body just as complete to tomcat.
Please see the packet capture file for details.

1.tcp packet I sent
POST /TestServlet/helloworld HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Transfer-Encoding: chunked


2.servlet code
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		System.out.println("doPost start");
		Enumeration pem = req.getParameterNames();
		while (pem.hasMoreElements()) {
			String k = pem.nextElement().toString();
			String v = req.getParameter(k);
			System.out.println(k + "=" + v);
		System.out.println("doPost end");



3.the current result 
the servlet outputs the following
doPost start
doPost end

4.the result I expected
doPost start
doPost end

Comment 1 charleschung.cn 2015-01-24 14:56:56 UTC
mod_jk is using apache httpd api to read (and de-chunk) the http body,so the cause may be in apache ,instead of mod_jk.

I am using Apache/2.2.15,after searching bug relating to chunked-transfering,I found https://issues.apache.org/bugzilla/show_bug.cgi?id=55475 which seems to relate to this one.
I will try upgrading apache to 2.2.18(at which version the issue 55475 is fixed) or higher to see the result
Comment 2 charleschung.cn 2015-01-24 16:57:13 UTC
Even after upgrading to the latest version of apache(2.4.10) + APR 1.5.1,noghting changes:the incomplete chunked-transfered body is still sent to tomcat(servlet).
Comment 3 Mark Thomas 2016-09-22 12:56:44 UTC
Thanks for the report. This has been fixed in trunk for 1.2.42 onwards.
Comment 4 Philippe Mouawad 2016-09-22 14:10:07 UTC
Hello Mark,
What's the expected release date for mod_jk 1.2.42 ?