#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