Ticket #4070 (closed defect: duplicate)

Opened 10 months ago

Last modified 10 months ago

WSGI module failing with POST parameters

Reported by: sergio.berna Owned by: jknight
Priority: normal Milestone:
Component: web Keywords: wsgi django post parameters
Cc: Branch:
Author: sergio.berna@experienceon.com Launchpad Bug:

Description

After combining django and twisted using the twisted.web.wsgi module I wasn't able to retrieve any POST parameter passed from the browser.

After some debugging I got to the twisted.wsgi._WSGIResponse there the "wsgi.input" parameter was initialized to a cStringIO object which was positioned to the end of the stream, and thus any call to the read method returned an empty string. That effectively prevented django or any other framework to extract the content of the stream and parse the POST parameters.

I have added a workaround consisting on performing a request.content.seek(0) to rewind the cStringIO object and allow the django request to correctly retrieve the post parameters.

+++ /usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-x86_64.egg/twisted/web/wsgi.py 2009-11-06 16:56:59.000000000 +0100 @@ -186,6 +186,7 @@ class _WSGIResponse:

self.environ[name] = ','.join([

v.replace('\n', ' ') for v in values])

+ request.content.seek(0)

self.environ.update({

'wsgi.version': (1, 0), 'wsgi.url_scheme': request.isSecure() and 'https' or 'http',

Change History

Changed 10 months ago by exarkun

  • status changed from new to closed
  • resolution set to duplicate

Duplicate of #3585.

Note: See TracTickets for help on using tickets.