mirror of
https://github.com/django/daphne.git
synced 2024-11-21 23:46:33 +03:00
Python 3 fixes
This commit is contained in:
parent
33ce841d29
commit
227c3ea2c4
|
@ -36,14 +36,14 @@ class WebRequest(http.Request):
|
|||
def process(self):
|
||||
# Get upgrade header
|
||||
upgrade_header = None
|
||||
if self.requestHeaders.hasHeader("Upgrade"):
|
||||
upgrade_header = self.requestHeaders.getRawHeaders("Upgrade")[0]
|
||||
if self.requestHeaders.hasHeader(b"Upgrade"):
|
||||
upgrade_header = self.requestHeaders.getRawHeaders(b"Upgrade")[0]
|
||||
# Calculate query string
|
||||
self.query_string = ""
|
||||
if b"?" in self.uri:
|
||||
self.query_string = self.uri.split(b"?", 1)[1]
|
||||
# Is it WebSocket? IS IT?!
|
||||
if upgrade_header == "websocket":
|
||||
if upgrade_header == b"websocket":
|
||||
# Make WebSocket protocol to hand off to
|
||||
protocol = self.factory.ws_factory.buildProtocol(self.transport.getPeer())
|
||||
if not protocol:
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||
import logging
|
||||
import time
|
||||
import traceback
|
||||
import urllib
|
||||
from six.moves.urllib.parse import urlencode
|
||||
|
||||
from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory
|
||||
|
||||
|
@ -31,7 +31,7 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
|||
clean_headers[name.lower()] = value[0].encode("latin1")
|
||||
# Reconstruct query string
|
||||
# TODO: get autobahn to provide it raw
|
||||
query_string = urllib.urlencode(request.params)
|
||||
query_string = urlencode(request.params).encode("ascii")
|
||||
# Make sending channel
|
||||
self.reply_channel = self.channel_layer.new_channel("!websocket.send.?")
|
||||
# Tell main factory about it
|
||||
|
|
Loading…
Reference in New Issue
Block a user