[PEAK] unicode in HTTP headers

Radek Kanovsky rk at dat.cz
Wed Dec 15 13:41:59 EST 2004


Hi,

peak.web.simpleRedirect function receives sometimes unicode string as
location argument from traversing machinery but wsgi publisher doesn't
like unicode in headers. Unicode ULRs are generated by Locations built
via sitemap as they have unicode component names.

The simillar case happens when content-type is specified in template.

I think that we can simply stringify unicode input in concerned methods.

RadekK


===================================================================
--- templates.py        (revision 32)
+++ templates.py        (working copy)
@@ -600,7 +600,7 @@
         )
         h = []
         if self.content_type:
-            h.append(('Content-type',self.content_type))
+            h.append(('Content-type',str(self.content_type)))
         return '200 OK', h, [str(unicodeJoin(data))]    # XXX encoding
 
===================================================================
--- environ.py  (revision 32)
+++ environ.py  (working copy)
@@ -307,7 +307,7 @@
         status="302 Found"
     else:
         status="303 See Other"
-    return status,[('Location',location)],()
+    return status,[('Location',str(location))],()
 
 



More information about the PEAK mailing list