Jon Dufresne
57a3d96ff5
Replaced unnecessary str()/bytes() calls with literals.
2019-11-18 15:30:10 +01:00
atsuo ishimoto
a9c6ab0356
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.
2019-07-10 13:22:17 +02:00
Jon Dufresne
76990cbbda
Fixed #30171 -- Fixed DatabaseError in servers tests.
...
Made DatabaseWrapper thread sharing logic reentrant. Used a reference
counting like scheme to allow nested uses.
The error appeared after 8c775391b7
.
2019-02-14 10:04:55 -05:00
Jon Dufresne
c492fdfd24
Removed default empty content argument from HttpResponse calls.
2019-02-09 16:27:32 -05:00
Jon Dufresne
7785e03ba8
Fixed #30137 -- Replaced OSError aliases with the canonical OSError.
...
Used more specific errors (e.g. FileExistsError) as appropriate.
2019-01-28 11:15:06 -05:00
Simon Charette
8c775391b7
Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases.
2019-01-10 19:11:21 -05:00
Tim Graham
043bd70942
Updated test URL patterns to use path() and re_path().
2018-12-31 10:47:32 -05:00
Konstantin Alekseev
b514dc14f4
Fixed #30015 -- Ensured request body is properly consumed for keep-alive connections.
2018-12-19 11:27:08 +01:00
Simon Charette
0f212db29d
Made reused RequestFactory instances class attributes.
2018-11-27 09:49:02 -05:00
Florian Apolloner
934acf1126
Fixed keep-alive support in manage.py 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 .
2018-11-10 13:54:45 +01:00
Claude Paroz
523e04dfeb
Captured logging in tests with self.assertLogs().
2018-05-07 09:34:02 -04:00
Claude Paroz
607970f31c
Replaced django.test.utils.patch_logger() with assertLogs().
...
Thanks Tim Graham for the review.
2018-05-07 09:34:00 -04:00
Tom
32ade78c55
Refs #28440 -- Fixed server connection closing test on macOS.
2017-10-13 13:29:29 -04:00
Tim Graham
cfff2af02b
Fixed #27857 -- Dropped support for Python 3.4.
2017-09-25 17:11:03 -04:00
Tom
ac756f16c5
Fixed #28440 -- Fixed WSGIServer hang on responses without a Content-Length.
...
Disabled keep-alive to fix the regression in
e6065c7b83
.
2017-09-12 10:41:28 -04:00
Jon Dufresne
a0f8c52ae2
Fixed ResourceWarnings in tests/servers/tests.py.
...
e.g. ResourceWarning: unclosed <socket.socket [closed] fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>
2017-06-05 09:56:51 -04:00
Robert Rollins
b6d4b6e544
Fixed #28212 -- Allowed customizing the port that LiveServerTestCase uses.
...
Forwardport of 877d7b71ae
from stable/1.11.x
2017-05-30 18:49:10 -04:00
Jon Dufresne
21046e7773
Fixed #28249 -- Removed unnecessary dict.keys() calls.
...
iter(dict) is equivalent to iter(dict.keys()).
2017-05-27 19:08:46 -04:00
Florian Apolloner
d611a89238
Decreased max_length for char fields unless absolutely needed. ( #8485 )
2017-05-10 17:33:46 +02:00
Claude Paroz
e6065c7b83
Fixed #25619 -- Made runserver serve with HTTP 1.1 protocol
...
Thanks Tim Graham for the review.
2017-02-23 09:04:53 +01:00
Nadège Michel
bece837829
Fixed #20238 -- Added threading support to LiveServerTestCase.
2017-02-09 19:08:32 -05:00
Tim Graham
500532c95d
Refs #23919 -- Removed default 'utf-8' argument for str.encode()/decode().
2017-02-09 09:03:47 -05:00
Claude Paroz
fee42fd99e
Refs #23919 -- Replaced usage of django.utils.http utilities with Python equivalents
...
Thanks Tim Graham for the review.
2017-01-26 19:49:03 +01:00
chillaranand
d6eaf7c018
Refs #23919 -- Replaced super(ClassName, self) with super().
2017-01-25 12:23:46 -05:00
Claude Paroz
042b7350a0
Refs #23919 -- Removed unneeded str() calls
2017-01-20 14:13:55 +01:00
Tim Graham
4e729feaa6
Refs #23919 -- Removed django.utils._os.upath()/npath()/abspathu() usage.
...
These functions do nothing on Python 3.
2017-01-20 08:01:02 -05:00
Simon Charette
9695b14982
Refs #23919 -- Removed str() conversion of type and method __name__.
2017-01-19 11:31:07 -05:00
Tim Graham
5320fa77c3
Refs #23919 -- Removed obsolete contextlib.closing() calls (for Python 2).
2017-01-19 08:50:28 -05:00
Simon Charette
cecc079168
Refs #23919 -- Stopped inheriting from object to define new style classes.
2017-01-19 08:39:46 +01:00
Claude Paroz
2b281cc35e
Refs #23919 -- Removed most of remaining six usage
...
Thanks Tim Graham for the review.
2017-01-18 21:33:28 +01:00
Claude Paroz
7b2f2e74ad
Refs #23919 -- Removed six.<various>_types usage
...
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-18 20:18:46 +01:00
Claude Paroz
d7b9aaa366
Refs #23919 -- Removed encoding preambles and future imports
2017-01-18 09:55:19 +01:00
za
321e94fa41
Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings.
2016-11-10 21:30:21 -05:00
Chris Jerdonek
f6cd669ff2
Fixed #22414 -- Ensured that LiveServerTestCase closes connections.
2016-08-19 12:47:41 -04:00
Tim Graham
35225e2ade
Refs #27025 -- Fixed a servers test on Python 3.6.
...
After https://hg.python.org/cpython/rev/4ea79767ff75/ ,
test_strips_underscore_headers fails with:
'Stub' object has no attribute 'sendall'.
2016-08-08 16:50:48 -04:00
Tim Graham
81cdcb66bc
Fixed #26791 -- Replaced LiveServerTestCase port ranges with binding to port 0.
2016-06-23 12:04:05 -04:00
Tim Graham
ea34426ae7
Fixed flake8 2.6 warnings.
2016-06-16 09:12:50 -04:00
Tim Graham
f0a84112ba
Refs #25684 -- Silenced logging output in servers tests.
2016-02-08 11:14:27 -05:00
Flavio Curella
0bc5cd6280
Fixed #25684 -- Made runserver use logging for request/response output.
...
Thanks andreif for the contributing to the patch.
2016-01-11 07:35:17 -05:00
Marten Kenbeek
b551eda9c5
Refs #26011 -- Fixed AttributeError in test_port_bind test.
2016-01-02 11:03:24 -05:00
Marten Kenbeek
c87540cee5
Fixed #26011 -- Prevented random LiveServerTestCase test failures on Windows.
...
Prevented LiveServerTestCase from stealing ports used by concurrent
processes on Windows.
2015-12-31 10:57:03 -05:00
Tim Graham
1a76257b1b
Fixed #25204 -- Added missing space in runserver logging.
2015-08-01 08:01:24 -04:00
Tim Graham
6e3fe089dd
Replaced six.BytesIO with io.BytesIO
2015-07-20 08:19:47 -04:00
Andriy Sokolovskiy
b40c551fdf
Fixed some unclosed objects in tests
2015-07-06 10:10:40 -04:00
Moritz Sichert
296919e7a5
Fixed #24965 -- Made LiveServerTestCase.live_server_url accessible from class
2015-06-12 17:44:54 -04:00
Simon Charette
be67400b47
Refs #24652 -- Used SimpleTestCase where appropriate.
2015-05-20 13:46:13 -04:00
Tim Graham
c8074d62f8
Fixed typo in error message in the test.
2015-02-19 19:36:20 -05:00
Tim Graham
0ed7d15563
Sorted imports with isort; refs #23860 .
2015-02-06 08:16:28 -05:00
Carl Meyer
316b8d4974
Stripped headers containing underscores to prevent spoofing in WSGI environ.
...
This is a security fix. Disclosure following shortly.
Thanks to Jedediah Smith for the report.
2015-01-13 13:03:05 -05:00
wrwrwr
6dbe979b4d
Fixed #23930 -- Added copies of captured_std* managers from CPython's test.support.
...
StringIO import was adapted for compatibility with Python 2.
2014-11-29 11:21:58 -05:00