[CherryPy] #811: CP WSGI requires a full read of request body

1 view
Skip to first unread message

CherryPy

unread,
May 6, 2008, 4:26:24 PM5/6/08
to cherrypy...@googlegroups.com
#811: CP WSGI requires a full read of request body
---------------------------+------------------------------------------------
Reporter: guest | Owner: fumanchu
Type: defect | Status: new
Priority: normal | Milestone:
Component: CherryPy code | Keywords:
---------------------------+------------------------------------------------
If a request body is not read then it is prepended to the REQUEST_METHOD
of the following request.

{{{
#!/usr/bin/python
# encoding: utf-8

import cherrypy.wsgiserver as wsgiserver
from webob import Request, Response

def wsgi_app(environ, start_response):
print environ['REQUEST_METHOD']
request = Request(environ)

print request.method

# FIXME: force a read of the request body (workaround for CherryPy)
# request.body

response = Response(body="<html><body><form method='post'><input
name='aaa' /></form></body></html>")
return response(environ, start_response)


server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 8080), wsgi_app)

if __name__ == '__main__':
try:
server.start()
except KeyboardInterrupt:
server.stop()
}}}

The first POST is OK, the second one has the body of the previous post
prepended to the request method:

Console output:
{{{GET
GET
POST
POST
aaa=aaaaaPOST
aaa=aaaaaPOST
}}}

Forcing a full read of the body gives a workaround for the problem.

(rev-1956 and 3.1.0-beta3)

--
Ticket URL: <http://www.cherrypy.org/ticket/811>
CherryPy <http://www.cherrypy.org>
CherryPy - a pythonic, object-oriented HTTP framework

CherryPy

unread,
May 6, 2008, 4:28:47 PM5/6/08
to cherrypy...@googlegroups.com
#811: CP WSGI requires a full read of request body
---------------------------+------------------------------------------------
Reporter: guest | Owner: fumanchu
Type: defect | Status: new
Priority: normal | Milestone:
Component: CherryPy code | Resolution:
Keywords: |
---------------------------+------------------------------------------------
Changes (by guest):

* cc: => pstra...@gmail.com

CherryPy

unread,
Jun 6, 2008, 5:56:58 PM6/6/08
to cherrypy...@googlegroups.com
#811: CP WSGI requires a full read of request body
------------------------+---------------------------------------------------
Reporter: guest | Owner: fumanchu
Type: defect | Status: new
Priority: normal | Milestone:
Component: wsgiserver | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Changes (by guest):

* component: CherryPy code => wsgiserver

CherryPy

unread,
Jun 29, 2008, 3:31:37 PM6/29/08
to cherrypy...@googlegroups.com
#811: CP WSGI requires a full read of request body
------------------------+---------------------------------------------------
Reporter: guest | Owner: fumanchu
Type: defect | Status: closed
Priority: normal | Milestone: 3.1
Component: wsgiserver | Resolution: worksforme
Keywords: |
------------------------+---------------------------------------------------
Changes (by fumanchu):

* milestone: => 3.1
* resolution: => worksforme
* status: new => closed

Comment:

Hmmm. Your demo works fine for me with CP trunk and webob trunk. Since
[1786] HTTPRequest.send_headers has said:

{{{
#!python
if (not self.close_connection) and (not self.chunked_read):
# Read any remaining request body data on the socket.
}}}

I wonder how you're avoiding that. It's probably not that close_connection
is True, because in that case the second request would be on its own conn.
Are you doing chunked reads? That seems highly unlikely, but even if you
were, wsgiserver currently reads the entire body into a StringIO before
calling the app. I'm baffled.
Reply all
Reply to author
Forward
0 new messages