]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Merge remote-tracking branch 'norman-labs/branch2.4'
authorBen Darnell <ben@bendarnell.com>
Fri, 15 Mar 2013 01:36:34 +0000 (21:36 -0400)
committerBen Darnell <ben@bendarnell.com>
Fri, 15 Mar 2013 01:42:49 +0000 (21:42 -0400)
Conflicts:
tornado/httputil.py

1  2 
tornado/httputil.py
tornado/test/httpserver_test.py

index b9cd10658013716ef9b40763dfddc4ddbf9fad1f,26b33cd0a84acdfee5290f9da8c7754f0556819d..f68c7414a53bae8deab820686106b5cb2b5e3478
@@@ -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"):
 -        for name, values in uri_arguments.iteritems():
 +        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.items():
              if values:
                  arguments.setdefault(name, []).extend(values)
      elif content_type.startswith("multipart/form-data"):
index 123ae2e70eb5bc8c6f02f03964067ec7c34d7e3d,7ee82b831085c69267f57dfd0d6793f837be8f34..54b38b464c03c3c1c4185d96dea8329f03c5b96c
@@@ -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("")]})
  
 -        self.assertEqual(data, {u"foo": [u""], u"bar": [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("")]})
      def test_types(self):
          headers = {"Cookie": "foo=bar"}
          response = self.fetch("/typecheck?foo=bar", headers=headers)