Commit 062086d2 authored by Jason Madden's avatar Jason Madden Committed by GitHub

Merge pull request #1490 from gevent/issue1331

gevent.pywsgi: Support keep-alive in HTTP/1.0
parents 9fe8ba12 6f734773
...@@ -43,6 +43,9 @@ ...@@ -43,6 +43,9 @@
calling it, so ``unlink`` can sometimes be optimized out. See calling it, so ``unlink`` can sometimes be optimized out. See
:issue:`1487`. :issue:`1487`.
- Make ``gevent.pywsgi`` support ``Connection: keep-alive`` in
HTTP/1.0. Based on :pr:`1331` by tanchuhan.
1.5a2 (2019-10-21) 1.5a2 (2019-10-21)
================== ==================
......
...@@ -555,7 +555,11 @@ class WSGIHandler(object): ...@@ -555,7 +555,11 @@ class WSGIHandler(object):
if self.request_version == "HTTP/1.1": if self.request_version == "HTTP/1.1":
conntype = self.headers.get("Connection", "").lower() conntype = self.headers.get("Connection", "").lower()
self.close_connection = (conntype == 'close') self.close_connection = (conntype == 'close')
elif self.request_version == 'HTTP/1.0':
conntype = self.headers.get("Connection", "close").lower()
self.close_connection = (conntype != 'keep-alive')
else: else:
# XXX: HTTP 0.9. We should drop support
self.close_connection = True self.close_connection = True
return True return True
...@@ -842,7 +846,7 @@ class WSGIHandler(object): ...@@ -842,7 +846,7 @@ class WSGIHandler(object):
self.response_headers = response_headers self.response_headers = response_headers
self.code = code self.code = code
provided_connection = None provided_connection = None # Did the wsgi app give us a Connection header?
self.provided_date = None self.provided_date = None
self.provided_content_length = None self.provided_content_length = None
...@@ -856,8 +860,8 @@ class WSGIHandler(object): ...@@ -856,8 +860,8 @@ class WSGIHandler(object):
self.provided_content_length = value self.provided_content_length = value
if self.request_version == 'HTTP/1.0' and provided_connection is None: if self.request_version == 'HTTP/1.0' and provided_connection is None:
response_headers.append((b'Connection', b'close')) conntype = b'close' if self.close_connection else b'keep-alive'
self.close_connection = True response_headers.append((b'Connection', conntype))
elif provided_connection == 'close': elif provided_connection == 'close':
self.close_connection = True self.close_connection = True
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment