Sometimes twisted.web.http.Request.requestReceived reads from the body object (Request.content) and parses the result into Request.args. Then it calls process. If a twisted.web.wsgi.WSGIResource is getting the request, it will be passed on as the wsgi.input in the environ to application code. This means that sometimes a wsgi application will get an already-read input and not be able to get the request body.

Change History (13)

Summary
changed from [PATCH] Request.content should be rewinded to the beginning before Request.process is called to If the Content-Type of a request is "application/x-www-form-urlencoded", twisted.web.wsgi gives applications a zero-length input object

Adjusting summary and description to more directly describe the problem, rather than describing a possible solution. The old description was:

This causes problem with the recently added twisted.web.wsgi.
If a POST Request's Content-Type equals to 'application/x-www-form-urlencoded', calling environwsgi.input?.read(...) in a wsgi app will return empty string since it had been read before in the Twisted framework.
Patch attached.

Ensure that Request.content is always positioned at the beginning of
the file before calling the process method. This simplifies handling
request bodies by making it never necessary to explicitly seek back to
the beginning of the file.