mirror of
https://github.com/django/daphne.git
synced 2024-11-22 16:06:34 +03:00
Try to handle HTTP version and SSL correctly (plus better errors)
This commit is contained in:
parent
3937489c4a
commit
4a764f7966
|
@ -49,6 +49,7 @@ class WebRequest(http.Request):
|
||||||
""".replace("\n", "").replace(" ", " ").replace(" ", " ").replace(" ", " ") # Shorten it a bit, bytes wise
|
""".replace("\n", "").replace(" ", " ").replace(" ", " ").replace(" ", " ") # Shorten it a bit, bytes wise
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
try:
|
||||||
http.Request.__init__(self, *args, **kwargs)
|
http.Request.__init__(self, *args, **kwargs)
|
||||||
# Easy factory link
|
# Easy factory link
|
||||||
self.factory = self.channel.factory
|
self.factory = self.channel.factory
|
||||||
|
@ -58,6 +59,8 @@ class WebRequest(http.Request):
|
||||||
self.last_keepalive = time.time()
|
self.last_keepalive = time.time()
|
||||||
self.factory.reply_protocols[self.reply_channel] = self
|
self.factory.reply_protocols[self.reply_channel] = self
|
||||||
self._got_response_start = False
|
self._got_response_start = False
|
||||||
|
except Exception:
|
||||||
|
logger.error(traceback.format_exc())
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
try:
|
try:
|
||||||
|
@ -156,11 +159,11 @@ class WebRequest(http.Request):
|
||||||
self.factory.channel_layer.send("http.request", {
|
self.factory.channel_layer.send("http.request", {
|
||||||
"reply_channel": self.reply_channel,
|
"reply_channel": self.reply_channel,
|
||||||
# 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": self.clientproto.split("/")[-1],
|
||||||
"method": self.method.decode("ascii"),
|
"method": self.method.decode("ascii"),
|
||||||
"path": self.unquote(self.path),
|
"path": self.unquote(self.path),
|
||||||
"root_path": self.root_path,
|
"root_path": self.root_path,
|
||||||
"scheme": "http",
|
"scheme": "https" if self.isSecure() else "http",
|
||||||
"query_string": self.query_string,
|
"query_string": self.query_string,
|
||||||
"headers": self.clean_headers,
|
"headers": self.clean_headers,
|
||||||
"body": self.content.read(),
|
"body": self.content.read(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user