[Zope3-checkins] CVS: Zope3/src/zope/publisher - http.py:1.49

Dmitry Vasiliev dima at hlabs.spb.ru
Mon Apr 5 04:16:35 EDT 2004


Update of /cvs-repository/Zope3/src/zope/publisher
In directory cvs.zope.org:/tmp/cvs-serv19233/src/zope/publisher

Modified Files:
	http.py 
Log Message:
Update "Content-Type" header with charset definition if necessary.


=== Zope3/src/zope/publisher/http.py 1.48 => 1.49 ===
--- Zope3/src/zope/publisher/http.py:1.48	Tue Mar 30 04:16:17 2004
+++ Zope3/src/zope/publisher/http.py	Mon Apr  5 04:16:00 2004
@@ -752,10 +752,14 @@
 
     def setCharset(self, charset=None):
         'See IHTTPResponse'
-        # XXX: Should set the appropriate response header for specifying the
-        #      encoding.
         self._charset = charset
 
+    def _updateContentType(self):
+        if self._charset is not None:
+            ctype = self.getHeader('content-type', '')
+            if ctype.startswith("text") and "charset" not in ctype:
+                self.setHeader('content-type',
+                        ctype + ";charset=" + self._charset)
 
     def setCharsetUsingRequest(self, request):
         'See IHTTPResponse'
@@ -891,6 +895,7 @@
         """
         if self._charset is None:
             self.setCharset('utf-8')
+        self._updateContentType()
         encode = self._encode
         headers = self.getHeaders()
         # Clean these headers from unicode by possibly encoding them




More information about the Zope3-Checkins mailing list