Commits

Robert Brewer committed 29deb0c

Fix for ticket #147 and buglet in _cphttptools.KeyTitlingDict.__del__.

Comments (0)

Files changed (3)

cherrypy/_cpdefaults.py

     content = "".join(traceback.format_exception(*sys.exc_info()))
     cpg.response.body = [content]
     cpg.response.headerMap['Content-Type'] = 'text/plain'
+    if cpg.response.headerMap.has_key('Content-Encoding'):
+        del cpg.response.headerMap['Content-Encoding']
+
 
 def _cpSaveSessionData(sessionId, sessionData, expirationTime,
         threadPool = None, sessionStorageType = None,

cherrypy/_cphttptools.py

     def __setitem__(self, key, value):
         dict.__setitem__(self, str(key).title(), value)
     
-    def __delitem__(self, key, value):
-        dict.__delitem__(self, str(key).title(), value)
+    def __delitem__(self, key):
+        dict.__delitem__(self, str(key).title())
     
     def __contains__(self, item):
         return dict.__contains__(self, str(item).title())
     
     # Headers
     cpg.response.headers = []
-    for key, valueList in cpg.response.headerMap.items():
+    for key, valueList in cpg.response.headerMap.iteritems():
         if not isinstance(valueList, list):
             valueList = [valueList]
         for value in valueList:

cherrypy/test/test_gzip_filter.py

     def index(self):
         yield "Hello, world"
     index.exposed = True
+    
+    def noshow(self):
+        # Test for ticket #147, where yield showed no exceptions (content-
+        # encoding was still gzip even though traceback wasn't zipped).
+        raise IndexError
+        yield "Here be dragons"
+    noshow.exposed = True
 
 cpg.root = Root()
 cpg.config.update({
         
         helper.request('/', headers=[("Accept-Encoding", "gzip")])
         self.assert_(zbuf.getvalue()[:3] in cpg.response.body)
+        
+        # Test for ticket #147
+        helper.request('/noshow', headers=[("Accept-Encoding", "gzip")])
+        self.assert_('Content-Encoding' not in cpg.response.headerMap)
+        self.assert_(cpg.response.body.endswith("IndexError\n"))
 
 
 if __name__ == "__main__":