[Zope-CVS] CVS: Packages/tcpwatch - tcpwatch:1.8

Shane Hathaway shane@cvs.zope.org
Thu, 21 Feb 2002 12:58:48 -0500


Update of /cvs-repository/Packages/tcpwatch
In directory cvs.zope.org:/tmp/cvs-serv4684

Modified Files:
	tcpwatch 
Log Message:
Proxy the request body.


=== Packages/tcpwatch/tcpwatch 1.7 => 1.8 ===
         self.headers = {}
         self.is_a_request = is_a_request
+        self.body_data = []
 
     def received(self, data):
         """Receives the HTTP stream for one request.
@@ -784,6 +785,7 @@
         else:
             # In body.
             consumed = br.received(data)
+            self.body_data.append(data[:consumed])
             if br.completed:
                 self.completed = 1
             return consumed
@@ -946,12 +948,14 @@
 
     def write(self, data):
         """Receives data from the HTTP server to be sent back to the client."""
-        while data:
+        while 1:
             parser = self.response_parser
             if parser.completed:
                 self.finished = 1
                 self.flush()
                 return
+            if not data:
+                break
             consumed = parser.received(data)
             fragment = data[:consumed]
             data = data[consumed:]
@@ -1085,6 +1089,8 @@
         # Duplicate the headers sent by the client.
         ep.write(request.header)
         ep.write('\r\n')
+        if request.body_data:
+            ep.write(''.join(request.body_data))
         ep.set_dests((buf,))
         ep.create_socket(socket.AF_INET, socket.SOCK_STREAM)
         ep.connect((host, port))