django1/django/core
Florian Apolloner e1721ece48 [2.1.x] Fixed #29849 -- Fixed keep-alive support in runserver.
Ticket #25619 changed the default protocol to HTTP/1.1 but did not
properly implement keep-alive. As a "fix" keep-alive was disabled in
ticket #28440 to prevent clients from hanging (they expect the server to
send more data if the connection is not closed and there is no content
length set).

The combination of those two fixes resulted in yet another problem:
HTTP/1.1 by default allows a client to assume that keep-alive is
supported unless the server disables it via 'Connection: close' -- see
RFC2616 8.1.2.1 for details on persistent connection negotiation. Now if
the client receives a response from Django without 'Connection: close'
and immediately sends a new request (on the same tcp connection) before
our server closes the tcp connection, it will error out at some point
because the connection does get closed a few milli seconds later.

This patch fixes the mentioned issues by always sending 'Connection:
close' if we cannot determine a content length. The code is inefficient
in the sense that it does not allow for persistent connections when
chunked responses are used, but that should not really cause any
problems (Django does not generate those) and it only affects the
development server anyways.

Refs #25619, #28440.

Regression in ac756f16c5.
Backport of 934acf1126 from master.
2018-11-20 17:44:03 -05:00
..
cache Fixed #27480 -- Added cache.touch(). 2018-04-27 17:48:35 -04:00
checks Removed unnecessary setdefault() from CheckRegistry.register(). 2018-02-26 08:54:55 -05:00
files [2.1.x] Fixed #29890 -- Fixed FileSystemStorage crash if concurrent saves try to create the same directory. 2018-10-31 20:24:16 -04:00
handlers [2.1.x] Refs #29784 -- Switched to https:// links where available. 2018-10-09 20:52:43 -04:00
mail Ref #23919 -- Replaced some os.path usage with pathlib.Path. 2018-04-19 21:30:00 -04:00
management [2.1.x] Fixed #29774 -- Fixed django-admin shell hang on startup. 2018-10-19 20:45:55 -04:00
serializers [2.1.x] Refs #29784 -- Switched to https:// links where available. 2018-10-09 20:52:43 -04:00
servers [2.1.x] Fixed #29849 -- Fixed keep-alive support in runserver. 2018-11-20 17:44:03 -05:00
__init__.py
exceptions.py Removed Python 2 comment in ValidationError. 2017-10-23 08:56:41 -04:00
paginator.py Fixed #29389 -- Made Paginator reject non-integer page numbers of type float. 2018-05-09 09:28:52 -04:00
signals.py Fixed #20349 -- Moved setting_changed signal to django.core.signals. 2014-12-24 07:18:43 -05:00
signing.py [2.1.x] Fixed signing.dumps() example for Python 3. 2018-11-09 07:27:03 -05:00
validators.py Ref #23919 -- Replaced some os.path usage with pathlib.Path. 2018-04-19 21:30:00 -04:00
wsgi.py Refs #27656 -- Updated django.core docstring verbs according to PEP 257. 2017-02-21 11:58:42 -05:00