Content-Length is not ignored for chunked requests: Nginx violates RFC 2616

agentzh agentzh at gmail.com
Fri Dec 18 05:52:16 MSK 2009


Hi,

I've noticed this issue while fixing bugs for my ngx_chunkin module,
reported by J.

Yeah, nginx explicitly checks the "chunked" transfer-encoding header
and throws out  a 411 Length Required exception as early as in the
ngx_http_process_request_header function. Well, trouble is,
ngx_http_finalize_request calls ngx_http_discard_request_body, which
eagerly reads and discards the request body according to a non-zero
Content-Length header in the request. But according to RFC 2616,
ngx_http_discard_request_body should really do NOTHING in this
scenario:

    If a message is received with both a
    Transfer-Encoding header field and a Content-Length header field
    the latter MUST be ignored.
                                                        -- RFC 2616 section 4.4

I can't easily work around this for my ngx_chunkin module because this
action is called just too early, even before ngx_http_process_request
gets called. Oh, well...and my users and I will have a BAD time if
I'll have to patch the core myself.

Lots of phones send chunked requests with an explicit Content-Length
header according to J's report. We're already reaching to the point to
support most phones completely by means of ngx_chunkin but
unfortunately hit this potentially last obstacle ;)

I'd really hope to see this issue gets fixed in the mainstream version
of nginx AND get a work-around for existing versions >= 0.7.21 ;)

Any help will be highly appreciated :)

Thanks!
-agentzh



More information about the nginx-devel mailing list