Commits

Robert Brewer committed 6146456

Fix for #951 (Content-Length breaks curl on 100-Continue) for 3.0, 3.1, 3.2 trunk.

  • Participants
  • Parent commits 76beee7

Comments (0)

Files changed (2)

File cherrypy/test/test_conn.py

         version, status, reason = response._read_status()
         self.assertEqual(status, 100)
         while True:
-            skip = response.fp.readline().strip()
-            if not skip:
+            line = response.fp.readline().strip()
+            if line:
+                self.fail("100 Continue should not output any headers. Got %r" % line)
+            else:
                 break
         
         # ...send the body

File cherrypy/wsgiserver/__init__.py

         # We used to do 3, but are now doing 1. Maybe we'll do 2 someday,
         # but it seems like it would be a big slowdown for such a rare case.
         if environ.get("HTTP_EXPECT", "") == "100-continue":
-            self.simple_response(100)
+            # Don't use simple_response here, because it emits headers
+            # we don't want. See http://www.cherrypy.org/ticket/951
+            msg = "%s 100 Continue\r\n\r\n" % self.environ['ACTUAL_SERVER_PROTOCOL']
+            try:
+                self.wfile.sendall(msg)
+            except socket.error, x:
+                if x.args[0] not in socket_errors_to_ignore:
+                    raise
         
         self.ready = True