2014-09-06 04:27:26 +08:00
|
|
|
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
|
2014-11-29 06:47:53 +08:00
|
|
|
from django.test.utils import captured_stderr
|
|
|
|
from django.utils.six import BytesIO
|
2014-09-06 04:27:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
2014-11-29 06:47:53 +08:00
|
|
|
with captured_stderr() as stderr:
|
2014-09-06 04:27:26 +08:00
|
|
|
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.",
|
2014-11-29 06:47:53 +08:00
|
|
|
stderr.getvalue()
|
2014-09-06 04:27:26 +08:00
|
|
|
)
|