From fd5928c1b15e539a64dfde89f4e537825a08b9a3 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 22 Jun 2016 09:42:43 -0700 Subject: [PATCH] Fix query string encoding to be bytes and not decoded --- daphne/http_protocol.py | 2 +- daphne/tests/test_http.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/daphne/http_protocol.py b/daphne/http_protocol.py index 6049c30..673ee6a 100755 --- a/daphne/http_protocol.py +++ b/daphne/http_protocol.py @@ -133,7 +133,7 @@ class WebRequest(http.Request): "path": self.unquote(self.path), "root_path": self.root_path, "scheme": "http", - "query_string": self.unquote(self.query_string, plus_as_space=True), + "query_string": self.query_string, "headers": self.clean_headers, "body": self.content.read(), "client": self.client_addr, diff --git a/daphne/tests/test_http.py b/daphne/tests/test_http.py index d0365a0..49d83ef 100644 --- a/daphne/tests/test_http.py +++ b/daphne/tests/test_http.py @@ -25,7 +25,7 @@ class TestHTTPProtocol(TestCase): """ # Send a simple request to the protocol 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"\r\n" ) @@ -35,7 +35,7 @@ class TestHTTPProtocol(TestCase): self.assertEqual(message['method'], "GET") self.assertEqual(message['scheme'], "http") 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.assertFalse(message.get("body", None)) self.assertTrue(message['reply_channel'])