PUT request and body data

179 views
Skip to first unread message

marc

unread,
Oct 7, 2009, 6:26:11 PM10/7/09
to Tornado Web Server
hi,

does tornado support body data in PUT requests. i've tried to get the
body params with self.get_argument('arg') but this doesn't work,
because self.request.arguments is empty.

firebug shows valid data in the body of the PUT request, but i can't
access this data in tornado.

thanks in advance,
marc

marc

unread,
Oct 7, 2009, 6:45:28 PM10/7/09
to Tornado Web Server
okay, i found the line that is responsible for parsing the body. the
following patch enables body data in PUT requests. maybe this can be
added to tornado? would be cool.

diff --git a/tornado/httpserver.py b/tornado/httpserver.py
index 460f5c8..60957c7 100644
--- a/tornado/httpserver.py
+++ b/tornado/httpserver.py
@@ -201,7 +201,7 @@ class HTTPConnection(object):
def _on_request_body(self, data):
self._request.body = data
content_type = self._request.headers.get("Content-Type", "")
- if self._request.method == "POST":
+ if self._request.method in ("POST", "PUT"):
if content_type.startswith("application/x-www-form-
urlencoded"):
arguments = cgi.parse_qs(self._request.body)
for name, values in arguments.iteritems():
Reply all
Reply to author
Forward
0 new messages