mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
no need to iter headers to find connection header since we could have it
the first time we get the list
This commit is contained in:
parent
1ac15b4bb2
commit
08fe410fb3
@ -19,6 +19,7 @@ class Message(object):
|
||||
def __init__(self, unreader):
|
||||
self.unreader = unreader
|
||||
self.version = None
|
||||
self.connection_hdr = None
|
||||
self.headers = []
|
||||
self.trailers = []
|
||||
self.body = None
|
||||
@ -55,7 +56,10 @@ class Message(object):
|
||||
while len(lines) and lines[0].startswith((" ", "\t")):
|
||||
value.append(lines.pop(0))
|
||||
value = ''.join(value).rstrip()
|
||||
|
||||
|
||||
if name == "CONNECTION":
|
||||
self.connection_hdr = value
|
||||
|
||||
headers.append((name, value))
|
||||
return headers
|
||||
|
||||
@ -84,14 +88,12 @@ class Message(object):
|
||||
self.body = Body(EOFReader(self.unreader))
|
||||
|
||||
def should_close(self):
|
||||
for (h, v) in self.headers:
|
||||
if h == "CONNECTION":
|
||||
v = v.lower().strip()
|
||||
if v == "close":
|
||||
return True
|
||||
elif v == "keep-alive":
|
||||
return False
|
||||
break
|
||||
if self.connection_hdr is not None:
|
||||
v = self.connection_hdr.lower().strip()
|
||||
if v == "close":
|
||||
return True
|
||||
elif v == "keep-alive":
|
||||
return False
|
||||
return self.version <= (1, 0)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user