mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix upgrade header. close #298 .
We were supposed to handled the upgrade header there but the way we extend the default headers imply we were sending 2 connections headers. Instead we are now testing if the upgrade header is present and keep it.
This commit is contained in:
parent
f3c3357c85
commit
4a0ba5c2e5
@ -157,6 +157,7 @@ class Response(object):
|
|||||||
self.headers_sent = False
|
self.headers_sent = False
|
||||||
self.response_length = None
|
self.response_length = None
|
||||||
self.sent = 0
|
self.sent = 0
|
||||||
|
self.upgrade = False
|
||||||
|
|
||||||
def force_close(self):
|
def force_close(self):
|
||||||
self.must_close = True
|
self.must_close = True
|
||||||
@ -192,11 +193,11 @@ class Response(object):
|
|||||||
elif util.is_hoppish(name):
|
elif util.is_hoppish(name):
|
||||||
if lname == "connection":
|
if lname == "connection":
|
||||||
# handle websocket
|
# handle websocket
|
||||||
if value.lower().strip() != "upgrade":
|
if value.lower().strip() == "upgrade":
|
||||||
continue
|
self.upgrade = True
|
||||||
else:
|
|
||||||
# ignore hopbyhop headers
|
# ignore hopbyhop headers
|
||||||
continue
|
continue
|
||||||
self.headers.append((name.strip(), str(value).strip()))
|
self.headers.append((name.strip(), str(value).strip()))
|
||||||
|
|
||||||
|
|
||||||
@ -215,9 +216,14 @@ class Response(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def default_headers(self):
|
def default_headers(self):
|
||||||
connection = "keep-alive"
|
# set the connection header
|
||||||
if self.should_close():
|
if self.upgrade:
|
||||||
|
connection = "upgrade"
|
||||||
|
elif self.should_close():
|
||||||
connection = "close"
|
connection = "close"
|
||||||
|
else:
|
||||||
|
connection = "keepalive"
|
||||||
|
|
||||||
headers = [
|
headers = [
|
||||||
"HTTP/%s.%s %s\r\n" % (self.req.version[0],
|
"HTTP/%s.%s %s\r\n" % (self.req.version[0],
|
||||||
self.req.version[1], self.status),
|
self.req.version[1], self.status),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user