Opened 5 years ago

Closed 5 years ago

#4070 defect closed duplicate (duplicate)

WSGI module failing with POST parameters

Reported by: sergio.berna Owned by:
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 (2)

comment:1 Changed 5 years ago by exarkun

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #3585.

comment:2 Changed 4 years ago by <automation>

  • Owner jknight deleted
Note: See TracTickets for help on using tickets.