mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #25619 -- Made runserver serve with HTTP 1.1 protocol
Thanks Tim Graham for the review.
This commit is contained in:
parent
007d4e030c
commit
e6065c7b83
3 changed files with 28 additions and 2 deletions
|
@ -4,11 +4,13 @@ Tests for django.core.servers.
|
|||
import errno
|
||||
import os
|
||||
import socket
|
||||
from http.client import HTTPConnection
|
||||
from urllib.error import HTTPError
|
||||
from urllib.parse import urlencode
|
||||
from urllib.request import urlopen
|
||||
|
||||
from django.test import LiveServerTestCase, override_settings
|
||||
from django.test.utils import captured_stdout
|
||||
|
||||
from .models import Person
|
||||
|
||||
|
@ -50,6 +52,20 @@ class LiveServerAddress(LiveServerBase):
|
|||
|
||||
|
||||
class LiveServerViews(LiveServerBase):
|
||||
def test_protocol(self):
|
||||
"""Launched server serves with HTTP 1.1."""
|
||||
with captured_stdout() as debug_output:
|
||||
conn = HTTPConnection(LiveServerViews.server_thread.host, LiveServerViews.server_thread.port)
|
||||
try:
|
||||
conn.set_debuglevel(1)
|
||||
conn.request('GET', '/example_view/', headers={"Connection": "keep-alive"})
|
||||
conn.getresponse().read()
|
||||
conn.request('GET', '/example_view/', headers={"Connection": "close"})
|
||||
conn.getresponse()
|
||||
finally:
|
||||
conn.close()
|
||||
self.assertEqual(debug_output.getvalue().count("reply: 'HTTP/1.1 200 OK"), 2)
|
||||
|
||||
def test_404(self):
|
||||
with self.assertRaises(HTTPError) as err:
|
||||
self.urlopen('/')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue