#23398: Attempting to access a manage.py runserver instance over HTTPS raises
UnicodeDecodeError
-------------------------------+--------------------
     Reporter:  coredumperror  |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  HTTP handling  |    Version:  1.6
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 I realize that the runserver command is not designed to function over
 HTTPS, but it would be much more useful for users who ''don't'' realize
 that (like the 1-hour-ago version of me) if the exception that Django
 throws from HTTPS access attempts was not an apparently random
 UnicodeDecodeError from the logging system.

 Right now, with Django 1.6.5, attempting to access any URL on a runserver
 instance over HTTPS will result in this traceback being shown multiple
 times in the server console:

 {{{
 Traceback (most recent call last):
   File
 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py",
 line 560, in process_request_thread
     self.finish_request(request, client_address)
   File
 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py",
 line 322, in finish_request
     self.RequestHandlerClass(request, client_address, self)
   File "/srv/ads/django/tmtpds/ve/lib/python2.6/site-
 packages/django/core/servers/basehttp.py", line 126, in __init__
     super(WSGIRequestHandler, self).__init__(*args, **kwargs)
   File
 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py",
 line 617, in __init__
     self.handle()
   File
 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/wsgiref/simple_server.py",
 line 131, in handle
     if not self.parse_request(): # An error code has been sent, just exit
   File
 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py",
 line 289, in parse_request
     self.send_error(400, "Bad request syntax (%r)" % requestline)
   File
 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py",
 line 357, in send_error
     self.send_response(code, message)
   File
 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py",
 line 374, in send_response
     self.log_request(code)
   File
 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py",
 line 411, in log_request
     self.requestline, str(code), str(size))
   File "/srv/ads/django/tmtpds/ve/lib/python2.6/site-
 packages/django/core/servers/basehttp.py", line 138, in log_message
     msg = "[%s] %s\n" % (self.log_date_time_string(), format % args)
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xcd in position 12:
 ordinal not in range(128)
 }}}

 It's not always exactly the same byte having problems, but it's always
 line 138 in `django/core/servers/basehttp.py`. The server is attempting to
 log an "HTTP 400: Bad request syntax" error, but it's failing to decode
 the URL from what it seems to think is unicode to ascii. From my googling,
 it appears that this is happening because the browser encrypts the URL,
 and runserver is getting that encrypted URL and having no idea what to do
 with it.

 It would be really helpful for uniformed users like my past self if this
 error were reported as "You can't use HTTPS with runserver" rather than
 what we're currently getting.

--
Ticket URL: <https://code.djangoproject.com/ticket/23398>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/056.fba0bba02e2ed09e6e0c1520af0e1f9f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to