Commits

Anonymous committed a3bf734

Fixed the header bug for non ascii headers in the unicode server.

Comments (0)

Files changed (1)

unicode_server.py

 
         return environ
 
+    def send_header(self, keyword, value):
+        """Send a MIME header."""
+        if self.request_version != 'HTTP/0.9':
+            self.wfile.write(('%s: %s\r\n' % (keyword, value))
+                .encode('iso-8859-1', 'strict'))
+
+        if keyword.lower() == 'connection':
+            if value.lower() == 'close':
+                self.close_connection = True
+            elif value.lower() == 'keep-alive':
+                self.close_connection = False
+
     def run_wsgi(self):
         app = self.server.app
         environ = self.make_environ()
         """Handle a single HTTP request."""
         self.raw_requestline = self.rfile.readline()
         if not self.raw_requestline:
-            self.close_connection = 1
+            self.close_connection = True
         elif self.parse_request():
             return self.run_wsgi()