HttpRequest with chunked encoding is not buffered

464 views
Skip to first unread message

tomas.b...@gmail.com

unread,
Oct 31, 2008, 4:45:30 PM10/31/08
to Django users
Hello,
I'm trying to receive a possibly large XML message via HttpRequest
(POST method) with chunked encoding. However, when I send a response,
I found out (using Wireshark) that the response is being sent before
the whole POST request body is available. I expected Django to be
buffering the chunks and that the request would be complete, but
that's apparently not happening...

I'm reading the body like this:
request.POST.values()[0]

(Which is probably a wrong way, but I don't know how to do it
otherwise.)

Thank for any help.
Tomas

Graham Dumpleton

unread,
Oct 31, 2008, 6:50:01 PM10/31/08
to Django users
What hosting mechanism are you using. Anything that uses WSGI (eg,
mod_wsgi, fastcgi/flup) or mod_python will not work as neither WSGI
specification or mod_python support chunked transfer encoding on
request content. Certainly for mod_python and mod_wsgi, it should give
an error back before even gets to Django saying that content length
required to be set.

Graham

Tomáš Brambora

unread,
Oct 31, 2008, 7:40:50 PM10/31/08
to django...@googlegroups.com
I have a standard Django installation without any changes in the
settings (except adding mysql db to the settings.py) and I'm sending
the message to localhost:8000, so there is no proxy or anything else
in the way. Still, the request body comes after me sending the
response...

Graham Dumpleton

unread,
Nov 1, 2008, 5:28:23 AM11/1/08
to Django users


On Nov 1, 10:40 am, "Tomáš Brambora" <tomas.bramb...@gmail.com> wrote:
> I have a standard Django installation without any changes in the
> settings (except adding mysql db to the settings.py) and I'm sending
> the message to localhost:8000, so there is no proxy or anything else
> in the way. Still, the request body comes after me sending the
> response...

As I said in the other similar thread you created about this.

If you are getting empty input on read, then you are using hosting
mechanism that doesn't properly filter out chunked request content as
not being supported and instead assumes that content length of
request was 0.

In other words, chunked request content is not supported. Most hosting
mechanisms will flag it as an error. The internal Django development
server appears just to assume that content length on request is 0
since Content-Length header wouldn't be set. Thus why you are seeing
no input.

Graham

> On Fri, Oct 31, 2008 at 11:50 PM, Graham Dumpleton
>
> <Graham.Dumple...@gmail.com> wrote:

tomas.b...@gmail.com

unread,
Nov 1, 2008, 11:37:06 AM11/1/08
to Django users
I actually am seeing some input, but it is divided into several, well,
chunks. I guess it's the same problem as seeing no input - I'd say
you're right and chunked encoding is silently unsupported (it would be
nice if Django said something though).
However, could you please suggest any workaround? If mod_python does
not work, what should I use? (My goal is to be able to receive chunked
requests in some normal way in my django application).

On Nov 1, 10:28 am, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:

Karen Tracey

unread,
Nov 1, 2008, 12:45:24 PM11/1/08
to django...@googlegroups.com
On Sat, Nov 1, 2008 at 11:37 AM, tomas.b...@gmail.com <tomas.b...@gmail.com> wrote:

I actually am seeing some input, but it is divided into several, well,
chunks. I guess it's the same problem as seeing no input - I'd say
you're right and chunked encoding is silently unsupported (it would be
nice if Django said something though).
However, could you please suggest any workaround? If mod_python does
not work, what should I use? (My goal is to be able to receive chunked
requests in some normal way in my django application).

Here's a workaround if you must used chunked requests with servers (apparently many) that don't support it:  you can send a chunked request through Apache's mod_proxy and force it to unchunk and add a content-length.  Described here:

http://www.atnan.com/2008/8/8/transfer-encoding-chunked-chunky-http

Karen
 
Reply all
Reply to author
Forward
0 new messages