mirror of
https://github.com/django/daphne.git
synced 2025-07-05 12:23:19 +03:00
Fixed #210: Fix query string to be bytes and not decoded
This commit is contained in:
parent
274feeb42f
commit
e890c48f3f
|
@ -135,11 +135,9 @@ class AsgiRequest(http.HttpRequest):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def GET(self):
|
def GET(self):
|
||||||
# Django will try and re-urldecode the string and interpret + as space;
|
# Django will try and re-urldecode the query string and interpret + as space;
|
||||||
# we re-encode + here to fix this.
|
# we re-encode it here to fix this.
|
||||||
return http.QueryDict(
|
return http.QueryDict(self.message.get('query_string', ''))
|
||||||
self.message.get('query_string', '').replace("+", "%2b").encode("utf8"),
|
|
||||||
)
|
|
||||||
|
|
||||||
def _get_post(self):
|
def _get_post(self):
|
||||||
if not hasattr(self, '_post'):
|
if not hasattr(self, '_post'):
|
||||||
|
|
|
@ -46,7 +46,7 @@ class RequestTests(ChannelTestCase):
|
||||||
"http_version": "1.1",
|
"http_version": "1.1",
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"path": "/test2/",
|
"path": "/test2/",
|
||||||
"query_string": "x=1&y=foo bar+baz",
|
"query_string": b"x=1&y=%26foo+bar%2Bbaz",
|
||||||
"headers": {
|
"headers": {
|
||||||
"host": b"example.com",
|
"host": b"example.com",
|
||||||
"cookie": b"test-time=1448995585123; test-value=yeah",
|
"cookie": b"test-time=1448995585123; test-value=yeah",
|
||||||
|
@ -65,7 +65,7 @@ class RequestTests(ChannelTestCase):
|
||||||
self.assertEqual(request.META["SERVER_NAME"], "10.0.0.2")
|
self.assertEqual(request.META["SERVER_NAME"], "10.0.0.2")
|
||||||
self.assertEqual(request.META["SERVER_PORT"], 80)
|
self.assertEqual(request.META["SERVER_PORT"], 80)
|
||||||
self.assertEqual(request.GET["x"], "1")
|
self.assertEqual(request.GET["x"], "1")
|
||||||
self.assertEqual(request.GET["y"], "foo bar+baz")
|
self.assertEqual(request.GET["y"], "&foo bar+baz")
|
||||||
self.assertEqual(request.COOKIES["test-time"], "1448995585123")
|
self.assertEqual(request.COOKIES["test-time"], "1448995585123")
|
||||||
self.assertEqual(request.COOKIES["test-value"], "yeah")
|
self.assertEqual(request.COOKIES["test-value"], "yeah")
|
||||||
self.assertFalse(request.POST)
|
self.assertFalse(request.POST)
|
||||||
|
|
|
@ -526,10 +526,7 @@ Keys:
|
||||||
* ``path``: Unicode string HTTP path from URL, with percent escapes decoded
|
* ``path``: Unicode string HTTP path from URL, with percent escapes decoded
|
||||||
and UTF8 byte sequences decoded into characters.
|
and UTF8 byte sequences decoded into characters.
|
||||||
|
|
||||||
* ``query_string``: Unicode string URL portion after the ``?``, already
|
* ``query_string``: Byte string URL portion after the ``?``, not url-decoded.
|
||||||
url-decoded, like ``path``. Optional, default is ``""``. ``+`` characters in
|
|
||||||
this portion should be interpreted by the application to be literal pluses,
|
|
||||||
not spaces.
|
|
||||||
|
|
||||||
* ``root_path``: Unicode string that indicates the root path this application
|
* ``root_path``: Unicode string that indicates the root path this application
|
||||||
is mounted at; same as ``SCRIPT_NAME`` in WSGI. Optional, defaults
|
is mounted at; same as ``SCRIPT_NAME`` in WSGI. Optional, defaults
|
||||||
|
|
Loading…
Reference in New Issue
Block a user