summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authoratsuo ishimoto <atsuoishimoto@gmail.com>2019-07-07 00:43:59 +0900
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-07-10 13:22:17 +0200
commita9c6ab03560424ed7dff24849c8ddaa3e1eae62e (patch)
treec1f53269e1b7edcfb568efc20275e9cdc82a40fb /django
parent00d4e6f8b587dcea147c51ece253dc54c461a11d (diff)
Fixed #30619 -- Made runserver --nothreading use single threaded WSGIServer.
Browsers often use multiple connections with Connection: keep-alive. If --nothreading is specified, the WSGI server cannot accept new connections until the old connection is closed, causing hangs. Force Connection: close when --nothreading option is used.
Diffstat (limited to 'django')
-rw-r--r--django/core/servers/basehttp.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py
index ef93e28f26..02957c51a2 100644
--- a/django/core/servers/basehttp.py
+++ b/django/core/servers/basehttp.py
@@ -101,6 +101,9 @@ class ServerHandler(simple_server.ServerHandler):
# connection.
if 'Content-Length' not in self.headers:
self.headers['Connection'] = 'close'
+ # Persistent connections require threading server.
+ elif not isinstance(self.request_handler.server, socketserver.ThreadingMixIn):
+ self.headers['Connection'] = 'close'
# Mark the connection for closing if it's set as such above or if the
# application sent the header.
if self.headers.get('Connection') == 'close':