mirror of
https://github.com/django/daphne.git
synced 2024-11-22 16:06:34 +03:00
Send paths and query strings pre-decoded as per updated ASGI spec
This commit is contained in:
parent
3d069c0427
commit
bce5cdf13d
|
@ -6,6 +6,7 @@ import time
|
||||||
|
|
||||||
from twisted.web import http
|
from twisted.web import http
|
||||||
from twisted.protocols.policies import ProtocolWrapper
|
from twisted.protocols.policies import ProtocolWrapper
|
||||||
|
from six.moves.urllib_parse import unquote_plus
|
||||||
|
|
||||||
from .ws_protocol import WebSocketProtocol, WebSocketFactory
|
from .ws_protocol import WebSocketProtocol, WebSocketFactory
|
||||||
|
|
||||||
|
@ -108,15 +109,24 @@ class WebRequest(http.Request):
|
||||||
# TODO: Correctly say if it's 1.1 or 1.0
|
# TODO: Correctly say if it's 1.1 or 1.0
|
||||||
"http_version": "1.1",
|
"http_version": "1.1",
|
||||||
"method": self.method.decode("ascii"),
|
"method": self.method.decode("ascii"),
|
||||||
"path": self.path,
|
"path": self.unquote(self.path),
|
||||||
"scheme": "http",
|
"scheme": "http",
|
||||||
"query_string": self.query_string,
|
"query_string": self.unquote(self.query_string),
|
||||||
"headers": self.clean_headers,
|
"headers": self.clean_headers,
|
||||||
"body": self.content.read(),
|
"body": self.content.read(),
|
||||||
"client": [self.client.host, self.client.port],
|
"client": [self.client.host, self.client.port],
|
||||||
"server": [self.host.host, self.host.port],
|
"server": [self.host.host, self.host.port],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def unquote(self, value):
|
||||||
|
"""
|
||||||
|
Python 2 and 3 compat layer for utf-8 unquoting
|
||||||
|
"""
|
||||||
|
if six.PY2:
|
||||||
|
return unquote_plus(value).decode("utf8")
|
||||||
|
else:
|
||||||
|
return unquote_plus(value.decode("ascii"))
|
||||||
|
|
||||||
def send_disconnect(self):
|
def send_disconnect(self):
|
||||||
"""
|
"""
|
||||||
Sends a disconnect message on the http.disconnect channel.
|
Sends a disconnect message on the http.disconnect channel.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user