mirror of
https://github.com/django/daphne.git
synced 2024-11-21 15:36:33 +03:00
Fix imports and use of six
This commit is contained in:
parent
51c2de3f8c
commit
db68c43de1
|
@ -17,6 +17,6 @@ install:
|
|||
script:
|
||||
- pytest
|
||||
- flake8
|
||||
- isort --check-only --recursive daphne tests
|
||||
- isort --check-only --diff --recursive daphne tests
|
||||
- unify --check-only --recursive --quote \" daphne tests
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import logging
|
||||
import time
|
||||
import traceback
|
||||
from urllib.parse import unquote
|
||||
|
||||
import six
|
||||
from twisted.internet.interfaces import IProtocolNegotiationFactory
|
||||
from twisted.protocols.policies import ProtocolWrapper
|
||||
from twisted.web import http
|
||||
from zope.interface import implementer
|
||||
|
||||
from six.moves.urllib_parse import unquote
|
||||
|
||||
from .utils import parse_x_forwarded_for
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -68,8 +66,8 @@ class WebRequest(http.Request):
|
|||
if hasattr(self.client, "host") and hasattr(self.client, "port"):
|
||||
# client.host and host.host are byte strings in Python 2, but spec
|
||||
# requires unicode string.
|
||||
self.client_addr = [six.text_type(self.client.host), self.client.port]
|
||||
self.server_addr = [six.text_type(self.host.host), self.host.port]
|
||||
self.client_addr = [str(self.client.host), self.client.port]
|
||||
self.server_addr = [str(self.host.host), self.host.port]
|
||||
else:
|
||||
self.client_addr = None
|
||||
self.server_addr = None
|
||||
|
@ -202,9 +200,6 @@ class WebRequest(http.Request):
|
|||
self.setResponseCode(message["status"])
|
||||
# Write headers
|
||||
for header, value in message.get("headers", {}):
|
||||
# Shim code from old ASGI version, can be removed after a while
|
||||
if isinstance(header, six.text_type):
|
||||
header = header.encode("latin1")
|
||||
self.responseHeaders.addRawHeader(header, value)
|
||||
logger.debug("HTTP %s response started for %s", message["status"], self.client_addr)
|
||||
elif message["type"] == "http.response.body":
|
||||
|
@ -283,7 +278,7 @@ class WebRequest(http.Request):
|
|||
self.handle_reply({
|
||||
"type": "http.response.body",
|
||||
"body": (self.error_template % {
|
||||
"title": six.text_type(status) + " " + status_text.decode("ascii"),
|
||||
"title": str(status) + " " + status_text.decode("ascii"),
|
||||
"body": body,
|
||||
}).encode("utf8"),
|
||||
})
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import logging
|
||||
import time
|
||||
import traceback
|
||||
from urllib.parse import unquote
|
||||
|
||||
import six
|
||||
from autobahn.twisted.websocket import ConnectionDeny, WebSocketServerFactory, WebSocketServerProtocol
|
||||
from twisted.internet import defer
|
||||
|
||||
from six.moves.urllib_parse import unquote
|
||||
|
||||
from .utils import parse_x_forwarded_for
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -44,8 +42,8 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
|||
peer = self.transport.getPeer()
|
||||
host = self.transport.getHost()
|
||||
if hasattr(peer, "host") and hasattr(peer, "port"):
|
||||
self.client_addr = [six.text_type(peer.host), peer.port]
|
||||
self.server_addr = [six.text_type(host.host), host.port]
|
||||
self.client_addr = [str(peer.host), peer.port]
|
||||
self.server_addr = [str(host.host), host.port]
|
||||
else:
|
||||
self.client_addr = None
|
||||
self.server_addr = None
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import string
|
||||
from urllib import parse
|
||||
|
||||
from hypothesis import strategies
|
||||
|
||||
from six.moves.urllib import parse
|
||||
|
||||
HTTP_METHODS = ["OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "TRACE", "CONNECT"]
|
||||
|
||||
# Unicode characters of the "Letter" category
|
||||
|
|
Loading…
Reference in New Issue
Block a user