Ticket #811 (defect)
Opened 5 days ago
Last modified 5 days ago
CP WSGI requires a full read of request body
Status: new
| Reported by: | guest | Assigned to: | fumanchu |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | CherryPy code | Keywords: | |
| Cc: | pstradomski@gmail.com |
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)
Change History
05/06/08 15:28:40: Modified by guest
- cc set to pstradomski@gmail.com.

