From: Ben Darnell Date: Sat, 24 Mar 2012 20:46:06 +0000 (-0700) Subject: Add HTTPServer's type test to WSGIApplication, and fix another python3 bug. X-Git-Tag: v2.3.0~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ffd170b0e901f8f11eea5b0f6839778529f7c87;p=thirdparty%2Ftornado.git Add HTTPServer's type test to WSGIApplication, and fix another python3 bug. --- diff --git a/tornado/test/wsgi_test.py b/tornado/test/wsgi_test.py index 66996c065..54c374065 100644 --- a/tornado/test/wsgi_test.py +++ b/tornado/test/wsgi_test.py @@ -1,6 +1,8 @@ from __future__ import absolute_import, division, with_statement from wsgiref.validate import validator +from tornado.escape import json_decode +from tornado.test.httpserver_test import TypeCheckHandler from tornado.testing import AsyncHTTPTestCase, LogTrapTestCase from tornado.util import b from tornado.web import RequestHandler @@ -39,6 +41,7 @@ class WSGIApplicationTest(AsyncHTTPTestCase, LogTrapTestCase): return WSGIContainer(validator(WSGIApplication([ ("/", HelloHandler), ("/path/(.*)", PathQuotingHandler), + ("/typecheck", TypeCheckHandler), ]))) def test_simple(self): @@ -49,6 +52,16 @@ class WSGIApplicationTest(AsyncHTTPTestCase, LogTrapTestCase): response = self.fetch("/path/foo%20bar%C3%A9") self.assertEqual(response.body, u"foo bar\u00e9".encode("utf-8")) + def test_types(self): + headers = {"Cookie": "foo=bar"} + response = self.fetch("/typecheck?foo=bar", headers=headers) + data = json_decode(response.body) + self.assertEqual(data, {}) + + response = self.fetch("/typecheck", method="POST", body="foo=bar", headers=headers) + data = json_decode(response.body) + self.assertEqual(data, {}) + # This is kind of hacky, but run some of the HTTPServer tests through # WSGIContainer and WSGIApplication to make sure everything survives # repeated disassembly and reassembly. diff --git a/tornado/wsgi.py b/tornado/wsgi.py index b756f7022..73e0af1bd 100644 --- a/tornado/wsgi.py +++ b/tornado/wsgi.py @@ -116,7 +116,7 @@ class HTTPRequest(object): self.query = environ.get("QUERY_STRING", "") if self.query: self.uri += "?" + self.query - arguments = cgi.parse_qs(self.query) + arguments = parse_qs_bytes(native_str(self.query)) for name, values in arguments.iteritems(): values = [v for v in values if v] if values: