mirror of
https://github.com/django/daphne.git
synced 2024-11-21 23:46:33 +03:00
Modify header sending to match ASGI spec.
This commit is contained in:
parent
94cd1bbc53
commit
0f5fe8b274
|
@ -65,19 +65,27 @@ class WebRequest(http.Request):
|
||||||
self.reply_channel = None
|
self.reply_channel = None
|
||||||
# Boring old HTTP.
|
# Boring old HTTP.
|
||||||
else:
|
else:
|
||||||
# Send request message
|
|
||||||
logging.debug("HTTP %s request for %s", self.method, self.reply_channel)
|
logging.debug("HTTP %s request for %s", self.method, self.reply_channel)
|
||||||
self.content.seek(0, 0)
|
self.content.seek(0, 0)
|
||||||
|
# Calculate query string
|
||||||
query_string = ""
|
query_string = ""
|
||||||
if "?" in self.uri:
|
if "?" in self.uri:
|
||||||
query_string = self.uri.split("?", 1)[1]
|
query_string = self.uri.split("?", 1)[1]
|
||||||
|
# Sanitize headers
|
||||||
|
headers = {}
|
||||||
|
for name, value in self.requestHeaders.getAllRawHeaders():
|
||||||
|
# Prevent CVE-2015-0219
|
||||||
|
if "_" in name:
|
||||||
|
continue
|
||||||
|
headers[name.lower()] = value[0]
|
||||||
|
# Send message
|
||||||
self.factory.channel_layer.send("http.request", {
|
self.factory.channel_layer.send("http.request", {
|
||||||
"reply_channel": self.reply_channel,
|
"reply_channel": self.reply_channel,
|
||||||
"method": self.method,
|
"method": self.method,
|
||||||
"path": self.path,
|
"path": self.path,
|
||||||
"scheme": "http",
|
"scheme": "http",
|
||||||
"query_string": query_string,
|
"query_string": query_string,
|
||||||
"headers": {k: v[0] for k, v in self.requestHeaders.getAllRawHeaders()},
|
"headers": 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],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user