From 004b34c67dbbb1c9601443d10cb26e0eb7b58deb Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Fri, 28 Apr 2017 02:36:16 +0200 Subject: [PATCH] Decode utf-8 QUERY_STRING when relevant (#623) Fixes #622. --- channels/handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/channels/handler.py b/channels/handler.py index cb1d2e6..f6bd821 100644 --- a/channels/handler.py +++ b/channels/handler.py @@ -57,9 +57,13 @@ class AsgiRequest(http.HttpRequest): self.path_info = self.path # HTTP basics self.method = self.message['method'].upper() + # fix https://github.com/django/channels/issues/622 + query_string = self.message.get('query_string', '') + if isinstance(query_string, bytes): + query_string = query_string.decode('utf-8') self.META = { "REQUEST_METHOD": self.method, - "QUERY_STRING": self.message.get('query_string', ''), + "QUERY_STRING": query_string, "SCRIPT_NAME": self.script_name, "PATH_INFO": self.path_info, # Old code will need these for a while