title: Django: set_cookie with special characters not working
body: <p>I am using Django 1.11 with Python 3.4 and can not save cookies with a special character. </p>
  
  <p>This problem occurs with the Django build in development server and also on my Apache2 productive server. So I guess this problem is not related to the webserver. </p>
  
  <p>Please see below a very small example with one special character from the Polish alphabet:</p>
  
  <pre><code>def test(request):
      response = HttpResponse("ERROR")
      response.set_cookie('br_last_name', 'ń')
      return respons
  </code></pre>
  
  <p>And this is the exception which I get:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 138, in run
      self.finish_response()
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 180, in finish_response
      self.write(data)
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 274, in write
      self.send_headers()
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 333, in send_headers
      self._write(bytes(self.headers))
    File "/usr/lib/python3.4/wsgiref/headers.py", line 142, in __bytes__
      return str(self).encode('iso-8859-1')
  UnicodeEncodeError: 'latin-1' codec can't encode character '\u0144' in position 115: ordinal not in range(256)
  ----------------------------------------
  Exception happened during processing of request from ('10.0.2.2', 51996)
  Traceback (most recent call last):
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 138, in run
      self.finish_response()
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 180, in finish_response
      self.write(data)
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 274, in write
      self.send_headers()
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 333, in send_headers
      self._write(bytes(self.headers))
    File "/usr/lib/python3.4/wsgiref/headers.py", line 142, in __bytes__
      return str(self).encode('iso-8859-1')
  UnicodeEncodeError: 'latin-1' codec can't encode character '\u0144' in position 115: ordinal not in range(256)
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 141, in run
      self.handle_error()
    File "/usr/local/lib/python3.4/dist-packages/django/core/servers/basehttp.py", line 88, in handle_error
      super(ServerHandler, self).handle_error()
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 368, in handle_error
      self.finish_response()
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 180, in finish_response
      self.write(data)
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 274, in write
      self.send_headers()
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 331, in send_headers
      if not self.origin_server or self.client_is_modern():
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 344, in client_is_modern
      return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
  TypeError: 'NoneType' object is not subscriptable
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/usr/lib/python3.4/socketserver.py", line 617, in process_request_thread
      self.finish_request(request, client_address)
    File "/usr/lib/python3.4/socketserver.py", line 344, in finish_request
      self.RequestHandlerClass(request, client_address, self)
    File "/usr/lib/python3.4/socketserver.py", line 673, in __init__
      self.handle()
    File "/usr/local/lib/python3.4/dist-packages/django/core/servers/basehttp.py", line 155, in handle
      handler.run(self.server.get_app())
    File "/usr/lib/python3.4/wsgiref/handlers.py", line 144, in run
      self.close()
    File "/usr/lib/python3.4/wsgiref/simple_server.py", line 35, in close
      self.status.split(' ',1)[0], self.bytes_sent
  AttributeError: 'NoneType' object has no attribute 'split'
  ----------------------------------------
  </code></pre>