Was doing a fresh install of my vagrant box and my dev environment and when trying to run my django project I get the following error. Any ideas whats going on?
----------------------------------------
[21/Sep/2013 23:44:03] code 400, message Bad HTTP/0.9 request type ('\x16\x03\x00\x00E\x01\x00\x00A\x03\x00R>u\xa6\x00`b\xceZ\xc8\xe6H2\x85')
----------------------------------------
Exception happened during processing of request from ('10.0.2.2', 60969)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 582, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/home/vagrant/hypnos-venv/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 150, in __init__
    super(WSGIRequestHandler, self).__init__(*args, **kwargs)
  File "/usr/lib/python2.7/SocketServer.py", line 638, in __init__
    self.handle()
  File "/usr/lib/python2.7/wsgiref/simple_server.py", line 117, in handle
    if not self.parse_request(): # An error code has been sent, just exit
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 281, in parse_request
    "Bad HTTP/0.9 request type (%r)" % command)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 368, in send_error
    self.send_response(code, message)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 385, in send_response
    self.log_request(code)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 422, in log_request
    self.requestline, str(code), str(size))
  File "/home/vagrant/hypnos-venv/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 162, in log_message
    msg = "[%s] %s\n" % (self.log_date_time_string(), format % args)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa6 in position 15: ordinal not in range(128)
                Looks like you tried to hit http website with https
Were you trying this with https?
I had the same problem and finally figured out it should be with http (no s) while in development. https encrypts your request, which is a bunch of gibberish as far as the development server is concerned.
From the stack trace it looks Django development server tries to log a request and fails because request is invalid.
Turns out that BaseHTTPServer simply logs the first line of raw HTTP request, so if your browser sends trash in request (who knows why) then development server might fail trying to log it. I would suggest using a development console or Firebug to check the request headers sent by browser. If this is the case, then whole situation is more of a test environment issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With