From 6318bae452d628d1f516e5f5bfc4f9512b66ce34 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sat, 29 Apr 2017 19:09:07 -0700 Subject: [PATCH] Fixed #110: Use raw WS query string rather than reconstructing it --- daphne/http_protocol.py | 2 ++ daphne/ws_protocol.py | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/daphne/http_protocol.py b/daphne/http_protocol.py index 26b5f11..0b5ffe2 100755 --- a/daphne/http_protocol.py +++ b/daphne/http_protocol.py @@ -108,6 +108,8 @@ class WebRequest(http.Request): self.setResponseCode(500) logger.warn("Could not make WebSocket protocol") self.finish() + # Give it the raw query string + protocol._raw_query_string = self.query_string # Port across transport protocol.set_main_factory(self.factory) transport, self.transport = self.transport, None diff --git a/daphne/ws_protocol.py b/daphne/ws_protocol.py index 6b630a2..2b22e94 100755 --- a/daphne/ws_protocol.py +++ b/daphne/ws_protocol.py @@ -42,9 +42,6 @@ class WebSocketProtocol(WebSocketServerProtocol): if b"_" in name: continue self.clean_headers.append((name.lower(), value.encode("latin1"))) - # Reconstruct query string - # TODO: get autobahn to provide it raw - query_string = urlencode(request.params, doseq=True).encode("ascii") # Make sending channel self.reply_channel = self.main_factory.make_send_channel() # Tell main factory about it @@ -72,7 +69,7 @@ class WebSocketProtocol(WebSocketServerProtocol): self.request_info = { "path": self.unquote(self.path), "headers": self.clean_headers, - "query_string": self.unquote(query_string), + "query_string": self._raw_query_string, # Passed by HTTP protocol "client": self.client_addr, "server": self.server_addr, "reply_channel": self.reply_channel,