From: Ben Darnell Date: Fri, 15 Mar 2013 01:36:34 +0000 (-0400) Subject: Merge remote-tracking branch 'norman-labs/branch2.4' X-Git-Tag: v3.0.0~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae166d72192d001be8c2b349a287a3027fb88db1;p=thirdparty%2Ftornado.git Merge remote-tracking branch 'norman-labs/branch2.4' Conflicts: tornado/httputil.py --- ae166d72192d001be8c2b349a287a3027fb88db1 diff --cc tornado/httputil.py index b9cd10658,26b33cd0a..f68c7414a --- a/tornado/httputil.py +++ b/tornado/httputil.py @@@ -233,9 -215,8 +233,11 @@@ def parse_body_arguments(content_type, that will be updated with the parsed contents. """ if content_type.startswith("application/x-www-form-urlencoded"): + uri_arguments = parse_qs_bytes(native_str(body)) + for name, values in uri_arguments.items(): + values = [v for v in values if v] + uri_arguments = parse_qs_bytes(native_str(body), keep_blank_values=True) - for name, values in uri_arguments.iteritems(): ++ for name, values in uri_arguments.items(): if values: arguments.setdefault(name, []).extend(values) elif content_type.startswith("multipart/form-data"): diff --cc tornado/test/httpserver_test.py index 123ae2e70,7ee82b831..54b38b464 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@@ -309,13 -300,13 +311,18 @@@ class HTTPServerTest(AsyncHTTPTestCase) def test_query_string_encoding(self): response = self.fetch("/echo?foo=%C3%A9") data = json_decode(response.body) - self.assertEqual(data, {u"foo": [u"\u00e9"]}) + self.assertEqual(data, {u("foo"): [u("\u00e9")]}) + + def test_empty_query_string(self): + response = self.fetch("/echo?foo=&foo=") + data = json_decode(response.body) + self.assertEqual(data, {u("foo"): [u(""), u("")]}) + def test_empty_post_parameters(self): + response = self.fetch("/echo", method="POST", body="foo=&bar=") + data = json_decode(response.body) - self.assertEqual(data, {u"foo": [u""], u"bar": [u""]}) ++ self.assertEqual(data, {u("foo"): [u("")], u("bar"): [u("")]}) + def test_types(self): headers = {"Cookie": "foo=bar"} response = self.fetch("/typecheck?foo=bar", headers=headers)