Handling Transfer-Encoding: chunked requests #862

kzahel opened this Issue Jul 30, 2013 · 2 comments


None yet
2 participants

kzahel commented Jul 30, 2013

I was using python httplib, which by default does POST multipart requests using transfer-encoding: chunked. Tornado unfortunately triggers the application request callback before reading the POST body (which is chunked, and may actually never finish, if the requester is bad :-). I could see how this could cause buffer overflows, so perhaps leaving this out was intentional?

Would you be open to me consider a patch and pull request to httpserver.py to handle this case?


bdarnell commented Aug 3, 2013

Are you sure httplib sends chunked requests? I can't find that in its code. Sending chunked requests is not advised because many servers don't support them and there's no mechanism like Accept-Encoding to negotiate for its use.

Tornado should at least be checking for the presence of an unsupported Transfer-Encoding and returning an error instead of leaving the unconsumed data in the IOStream. It would be nice to fully support chunked encoding as well (probably by factoring the body-reading code out of simple_httpclient and using the same code for both client and server), although as you've noticed requests that have a legitimate need to be sent chunked are also likely to be big enough that streaming is desirable. It probably makes the most sense to tackle chunked requests after the HTTPServer streaming interface is present.


bdarnell commented Apr 28, 2014

In the master branch HTTPServer now supports chunked uploads.

@bdarnell bdarnell closed this Apr 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment