Jetty

Response handled before finishing request parsing using AJP connector with chunked data

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 6.1.4
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Ubuntu 7.04
    Apache/2.2.3 (mod_proxy_ajp)
  • Number of attachments :
    5

Description

I use apache and mod_proxy_ajp for communicating with jetty.

When a client tries to send data to the server and the request is chunked,
i can not retrieve request parameters, just null values but no errors.

Indeed, after analysing the stream using wireshark i have the following request / response in this order :
----------------------------------------------------------------------------------
POST /_log HTTP/1.1

Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5

Content-Type: application/x-www-form-urlencoded

Host: host
Transfer-Encoding: chunked

HTTP/1.1 200 OK

Date: Tue, 31 Jul 2007 14:45:08 GMT

Server: Server: Jetty(6.0.x)

Content-Length: 0

Content-Type: text/plain

7e0

data=...&data2=...

19f

...

0

----------------------------------------------------------------------------------

I have not this problem using Apache with mod_proxy_http and the standard HTTP connector in jetty
or using directly Jetty.

After launching jetty in debug, i found in Ajp13Parser.java and especially the method blockForContent
that the parsing is stopped if the Content-Length header is not present, therefore _contentLength variable
will be HttpTokens.NO_CONTENT or HttpTokens.UNKNOWN_CONTENT.

But, i have read that this Content-Length header is not mandatory for chunked request.

I do not know if this part of the HTTP protocol is handled by mod_proxy_ajp or if it is up to jetty.

  1. ajp_patch_20070803.patch
    03/Aug/07 11:08 AM
    21 kB
    Leopoldo Agdeppa III
  2. ajp_patch_20070806.patch
    06/Aug/07 1:26 AM
    3 kB
    Greg Wilkins
  3. ajp_patch_20070806-2.patch
    06/Aug/07 1:51 AM
    3 kB
    Greg Wilkins
  4. ajp_patch_20070806-4.patch
    06/Aug/07 6:37 AM
    7 kB
    Leopoldo Agdeppa III
  5. JETTY-407-ajp-response-before-request-wireshark.dump
    01/Aug/07 3:49 AM
    6 kB
    Sebastien Launay

Activity

Hide
Sebastien Launay added a comment -

The real stream without \r\n pairs, this must be easier to read
----------------------------------------------------------------------------------
POST /_log HTTP/1.1
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5
Content-Type: application/x-www-form-urlencoded
Host: host
Transfer-Encoding: chunked

HTTP/1.1 200 OK
Date: Tue, 31 Jul 2007 14:45:08 GMT
Server: Server: Jetty(6.0.x)
Content-Length: 0
Content-Type: text/plain

7e0
data=...&data2=...
19f
...
0

----------------------------------------------------------------------------------

Show
Sebastien Launay added a comment - The real stream without \r\n pairs, this must be easier to read ---------------------------------------------------------------------------------- POST /_log HTTP/1.1 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5 Content-Type: application/x-www-form-urlencoded Host: host Transfer-Encoding: chunked HTTP/1.1 200 OK Date: Tue, 31 Jul 2007 14:45:08 GMT Server: Server: Jetty(6.0.x) Content-Length: 0 Content-Type: text/plain 7e0 data=...&data2=... 19f ... 0 ----------------------------------------------------------------------------------
Hide
Leopoldo Agdeppa III added a comment -

Sébastien Launay

can you please attach the wireshark data, ill take a look, if its jetty-ajp bug or mod_proxy_ajp

thanks
bong

Show
Leopoldo Agdeppa III added a comment - Sébastien Launay can you please attach the wireshark data, ill take a look, if its jetty-ajp bug or mod_proxy_ajp thanks bong
Hide
Leopoldo Agdeppa III added a comment -

Sébastien Launay

ill try to reproduce the bug by sending packets using you wireshark dump, please send it to me, this will be a very good help in fixing this problem

thanks
bong

Show
Leopoldo Agdeppa III added a comment - Sébastien Launay ill try to reproduce the bug by sending packets using you wireshark dump, please send it to me, this will be a very good help in fixing this problem thanks bong
Hide
Sebastien Launay added a comment -

There is it.
I have just changed the POST data, both tcpdump and wireshark
can read it back, so this may not be a problem.

I have tried the following options on mod_proxy for my virtual host without success :
SetEnv proxy-sendcl 1
and then
SetEnv proxy-sendchunked 1

Thanks.
Sébastien Launay.

Show
Sebastien Launay added a comment - There is it. I have just changed the POST data, both tcpdump and wireshark can read it back, so this may not be a problem. I have tried the following options on mod_proxy for my virtual host without success : SetEnv proxy-sendcl 1 and then SetEnv proxy-sendchunked 1 Thanks. Sébastien Launay.
Hide
Leopoldo Agdeppa III added a comment -

I think im going to refactor the content_length checking

Show
Leopoldo Agdeppa III added a comment - I think im going to refactor the content_length checking
Hide
Leopoldo Agdeppa III added a comment -

I think we need to re factor the AJP13Parser, its current handling of content was based on content-length, and its decision for getting the next content was mainly based on
content-lenght and content received, because of this the current implementation is not able to parse contents if the content is unknown.

Show
Leopoldo Agdeppa III added a comment - I think we need to re factor the AJP13Parser, its current handling of content was based on content-length, and its decision for getting the next content was mainly based on content-lenght and content received, because of this the current implementation is not able to parse contents if the content is unknown.
Hide
Leopoldo Agdeppa III added a comment -

Attached is a patch on AJP13 patch for the fix of Transfer-Encoding chunked problem, on posting a chunked data,
also attached is a test case for submitting chunked http request, I will convert this to junit this comming Tuesday,
this has been already tested a couple of times, and other functionalities are also tested, they work perfectly

Show
Leopoldo Agdeppa III added a comment - Attached is a patch on AJP13 patch for the fix of Transfer-Encoding chunked problem, on posting a chunked data, also attached is a test case for submitting chunked http request, I will convert this to junit this comming Tuesday, this has been already tested a couple of times, and other functionalities are also tested, they work perfectly
Hide
Leopoldo Agdeppa III added a comment -

FIXED

Show
Leopoldo Agdeppa III added a comment - FIXED
Hide
Greg Wilkins added a comment -

A cleaner version of the patch without formatting changes

Show
Greg Wilkins added a comment - A cleaner version of the patch without formatting changes
Hide
Greg Wilkins added a comment -

an even simpler version of the patch

Show
Greg Wilkins added a comment - an even simpler version of the patch
Hide
Leopoldo Agdeppa III added a comment -

Attached is A patch with only the fix is included

Show
Leopoldo Agdeppa III added a comment - Attached is A patch with only the fix is included
Hide
Leopoldo Agdeppa III added a comment -

There was really no problem with handling chunked content, because this is handled by the _contentView.update(chunk)
The problem was only with unknown content length

Mod_jk and mod_proxy_ajp doesnt send a data for its content_length when content length is not given by http post request.
initially the _contentLength = HttpTokens.UNKNOWN_CONTENT which is equivalent to -3,

after handling the headers,
UNKNOWN_CONTENT was handled as NO_CONTENT,
the fix now send a get_more packet when UNKNOWN_CONTENT is encountered, after sending the packet, a send body request packet is filled(),
at this point, we are now ready to handle the new content packet if there is any

Show
Leopoldo Agdeppa III added a comment - There was really no problem with handling chunked content, because this is handled by the _contentView.update(chunk) The problem was only with unknown content length Mod_jk and mod_proxy_ajp doesnt send a data for its content_length when content length is not given by http post request. initially the _contentLength = HttpTokens.UNKNOWN_CONTENT which is equivalent to -3, after handling the headers, UNKNOWN_CONTENT was handled as NO_CONTENT, the fix now send a get_more packet when UNKNOWN_CONTENT is encountered, after sending the packet, a send body request packet is filled(), at this point, we are now ready to handle the new content packet if there is any
Hide
Sebastien Launay added a comment -

Great, the last patch (ajp_patch_20070806-4.patch) fixes my configuration.

Now i can receive POST data, thanks .

Show
Sebastien Launay added a comment - Great, the last patch (ajp_patch_20070806-4.patch) fixes my configuration. Now i can receive POST data, thanks .
Hide
Leopoldo Agdeppa III added a comment -

Sébastien Launay

Is it ok if I may ask, What http client are you using for this? took me a lot of time just to reproduce this with the browser

thanks
bong

Show
Leopoldo Agdeppa III added a comment - Sébastien Launay Is it ok if I may ask, What http client are you using for this? took me a lot of time just to reproduce this with the browser thanks bong
Hide
Sebastien Launay added a comment -

Requests came from a midlet application, especially from JVM from a mobile phone, you can reproduce it by using Sun Wireless Toolkit internal HTTP client.

Show
Sebastien Launay added a comment - Requests came from a midlet application, especially from JVM from a mobile phone, you can reproduce it by using Sun Wireless Toolkit internal HTTP client.
Hide
Leopoldo Agdeppa III added a comment -

Sébastien Launay

thanks, just curious

Show
Leopoldo Agdeppa III added a comment - Sébastien Launay thanks, just curious
Hide
Leopoldo Agdeppa III added a comment -

got errors creating the patch, anyway here again

Show
Leopoldo Agdeppa III added a comment - got errors creating the patch, anyway here again

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: