Switch to uncode path and query string for HTTP

This commit is contained in:
Andrew Godwin 2016-04-26 13:33:26 +01:00
parent 7945859bb2
commit e684b27e46

View File

@ -41,8 +41,8 @@ class AsgiRequest(http.HttpRequest):
self._post_parse_error = False self._post_parse_error = False
self.resolver_match = None self.resolver_match = None
# Path info # Path info
self.path = self.message['path'].decode("ascii") self.path = self.message['path']
self.script_name = self.message.get('root_path', b'') self.script_name = self.message.get('root_path', '')
if self.script_name: if self.script_name:
# TODO: Better is-prefix checking, slash handling? # TODO: Better is-prefix checking, slash handling?
self.path_info = self.path[len(self.script_name):] self.path_info = self.path[len(self.script_name):]
@ -52,8 +52,8 @@ class AsgiRequest(http.HttpRequest):
self.method = self.message['method'].upper() self.method = self.message['method'].upper()
self.META = { self.META = {
"REQUEST_METHOD": self.method, "REQUEST_METHOD": self.method,
"QUERY_STRING": self.message.get('query_string', b'').decode("ascii"), "QUERY_STRING": self.message.get('query_string', ''),
"SCRIPT_NAME": self.script_name.decode("ascii"), "SCRIPT_NAME": self.script_name,
# Old code will need these for a while # Old code will need these for a while
"wsgi.multithread": True, "wsgi.multithread": True,
"wsgi.multiprocess": True, "wsgi.multiprocess": True,
@ -133,10 +133,7 @@ class AsgiRequest(http.HttpRequest):
@cached_property @cached_property
def GET(self): def GET(self):
return http.QueryDict( return http.QueryDict(self.message.get('query_string', '').encode("utf8"))
self.message.get('query_string', ''),
encoding=self._encoding,
)
def _get_post(self): def _get_post(self):
if not hasattr(self, '_post'): if not hasattr(self, '_post'):