Commits

Robert Brewer committed de6021a

Test and fix for #864 (response.stream and HEAD method).

Comments (0)

Files changed (2)

cherrypy/test/test_conn.py

                     
                     # Make another request on the same connection, which should error.
                     self.assertRaises(httplib.NotConnected, self.getPage, "/")
+                
+                # Try HEAD. See http://www.cherrypy.org/ticket/864.
+                self.getPage("/stream", method='HEAD')
+                self.assertStatus('200 OK')
+                self.assertBody('')
+                self.assertNoHeader("Transfer-Encoding")
         else:
             self.PROTOCOL = "HTTP/1.0"
             

cherrypy/wsgiserver/__init__.py

             if status < 200 or status in (204, 205, 304):
                 pass
             else:
-                if self.response_protocol == 'HTTP/1.1':
+                if (self.response_protocol == 'HTTP/1.1'
+                    and self.environ["REQUEST_METHOD"] != 'HEAD'):
                     # Use the chunked transfer-coding
                     self.chunked_write = True
                     self.outheaders.append(("Transfer-Encoding", "chunked"))