Fix query string encoding to be bytes and not decoded

This commit is contained in:
Andrew Godwin 2016-06-22 09:42:43 -07:00
parent e02fa95987
commit fd5928c1b1
2 changed files with 3 additions and 3 deletions

View File

@ -133,7 +133,7 @@ class WebRequest(http.Request):
"path": self.unquote(self.path), "path": self.unquote(self.path),
"root_path": self.root_path, "root_path": self.root_path,
"scheme": "http", "scheme": "http",
"query_string": self.unquote(self.query_string, plus_as_space=True), "query_string": self.query_string,
"headers": self.clean_headers, "headers": self.clean_headers,
"body": self.content.read(), "body": self.content.read(),
"client": self.client_addr, "client": self.client_addr,

View File

@ -25,7 +25,7 @@ class TestHTTPProtocol(TestCase):
""" """
# Send a simple request to the protocol # Send a simple request to the protocol
self.proto.dataReceived( self.proto.dataReceived(
b"GET /te%20st-%C3%A0/?foo=bar HTTP/1.1\r\n" + b"GET /te%20st-%C3%A0/?foo=+bar HTTP/1.1\r\n" +
b"Host: somewhere.com\r\n" + b"Host: somewhere.com\r\n" +
b"\r\n" b"\r\n"
) )
@ -35,7 +35,7 @@ class TestHTTPProtocol(TestCase):
self.assertEqual(message['method'], "GET") self.assertEqual(message['method'], "GET")
self.assertEqual(message['scheme'], "http") self.assertEqual(message['scheme'], "http")
self.assertEqual(message['path'], "/te st-à/") self.assertEqual(message['path'], "/te st-à/")
self.assertEqual(message['query_string'], "foo=bar") self.assertEqual(message['query_string'], b"foo=+bar")
self.assertEqual(message['headers'], [(b"host", b"somewhere.com")]) self.assertEqual(message['headers'], [(b"host", b"somewhere.com")])
self.assertFalse(message.get("body", None)) self.assertFalse(message.get("body", None))
self.assertTrue(message['reply_channel']) self.assertTrue(message['reply_channel'])