mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #23398 -- Added helpful error message when runserver is accessed via HTTPS
This commit is contained in:
committed by
Tim Graham
parent
c32bc1a7a7
commit
c53f2451a8
27
tests/servers/test_basehttp.py
Normal file
27
tests/servers/test_basehttp.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import sys
|
||||
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.core.servers.basehttp import WSGIRequestHandler
|
||||
from django.test import TestCase
|
||||
from django.test.client import RequestFactory
|
||||
from django.utils.six import BytesIO, StringIO
|
||||
|
||||
|
||||
class WSGIRequestHandlerTestCase(TestCase):
|
||||
def test_https(self):
|
||||
request = WSGIRequest(RequestFactory().get('/').environ)
|
||||
request.makefile = lambda *args, **kwargs: BytesIO()
|
||||
|
||||
handler = WSGIRequestHandler(request, '192.168.0.2', None)
|
||||
|
||||
_stderr = sys.stderr
|
||||
sys.stderr = StringIO()
|
||||
try:
|
||||
handler.log_message("GET %s %s", str('\x16\x03'), "4")
|
||||
self.assertIn(
|
||||
"You're accessing the developement server over HTTPS, "
|
||||
"but it only supports HTTP.",
|
||||
sys.stderr.getvalue()
|
||||
)
|
||||
finally:
|
||||
sys.stderr = _stderr
|
||||
Reference in New Issue
Block a user