Fixed #110: Use raw WS query string rather than reconstructing it

This commit is contained in:
Andrew Godwin 2017-04-29 19:09:07 -07:00
parent 2bcec3fe94
commit 6318bae452
2 changed files with 3 additions and 4 deletions

View File

@ -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

View File

@ -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,