mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
add headers_sent guard.
This commit is contained in:
parent
125392d054
commit
9f572bc8ea
@ -54,6 +54,7 @@ class Request(object):
|
|||||||
self.start_response_called = False
|
self.start_response_called = False
|
||||||
self.log = logging.getLogger(__name__)
|
self.log = logging.getLogger(__name__)
|
||||||
self.response_chunked = False
|
self.response_chunked = False
|
||||||
|
self.headers_sent = False
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
environ = {}
|
environ = {}
|
||||||
@ -156,7 +157,7 @@ class Request(object):
|
|||||||
def start_response(self, status, response_headers, exc_info=None):
|
def start_response(self, status, response_headers, exc_info=None):
|
||||||
if exc_info:
|
if exc_info:
|
||||||
try:
|
try:
|
||||||
if self.start_response_called:
|
if self.headers_sent:
|
||||||
raise exc_info[0], exc_info[1], exc_info[2]
|
raise exc_info[0], exc_info[1], exc_info[2]
|
||||||
finally:
|
finally:
|
||||||
exc_info = None
|
exc_info = None
|
||||||
|
|||||||
@ -29,6 +29,8 @@ class Response(object):
|
|||||||
resp_head = self.default_headers()
|
resp_head = self.default_headers()
|
||||||
resp_head.extend(["%s: %s\r\n" % (n, v) for n, v in self.headers])
|
resp_head.extend(["%s: %s\r\n" % (n, v) for n, v in self.headers])
|
||||||
write(self._sock, "%s\r\n" % "".join(resp_head))
|
write(self._sock, "%s\r\n" % "".join(resp_head))
|
||||||
|
self.req.headers_sent = True
|
||||||
|
|
||||||
|
|
||||||
last_chunk = None
|
last_chunk = None
|
||||||
for chunk in self.data:
|
for chunk in self.data:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user