Commits

Robert Brewer committed 43c35dd

Fix for #561 (non-string WSGI response headers).

  • Participants
  • Parent commits 7338c52

Comments (0)

Files changed (1)

File cherrypy/_cpwsgiserver.py

             self.outheaders.append(("Server", server.version))
         
         wfile.write(server.protocol + " " + self.status + "\r\n")
-        for k, v in self.outheaders:
-            wfile.write(k + ": " + v + "\r\n")
+        try:
+            for k, v in self.outheaders:
+                wfile.write(k + ": " + v + "\r\n")
+        except TypeError:
+            if not isinstance(k, str):
+                raise TypeError("WSGI response header key %r is not a string.")
+            if not isinstance(v, str):
+                raise TypeError("WSGI response header value %r is not a string.")
+            else:
+                raise
         wfile.write("\r\n")
         wfile.flush()