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