[Inteproxy-commits] r332 - in branches/streaming: . inteproxy

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jan 3 18:31:30 CET 2012


Author: teichmann
Date: 2012-01-03 18:31:29 +0100 (Tue, 03 Jan 2012)
New Revision: 332

Modified:
   branches/streaming/ChangeLog
   branches/streaming/inteproxy/proxycore.py
Log:
Fixed Content-length bug if the content of a none chunked request is rewritten.

Modified: branches/streaming/ChangeLog
===================================================================
--- branches/streaming/ChangeLog	2012-01-03 16:29:56 UTC (rev 331)
+++ branches/streaming/ChangeLog	2012-01-03 17:31:29 UTC (rev 332)
@@ -1,5 +1,12 @@
 2012-01-03	Sascha L. Teichmann	<sascha.teichmann at intevation.de>
 
+	* inteproxy/proxycore.py: Fixed: If a response is rewritten in
+	  the none chunk case the value of Content-Length changes.
+	  So this header can only be written out if the replacement
+	  is already done to determine the correct size.
+
+2012-01-03	Sascha L. Teichmann	<sascha.teichmann at intevation.de>
+
 	* inteproxy/chunkedwriter.py, inteproxy/transcoder.py,
 	  inteproxy/proxycore.py: Added doc strings.
 

Modified: branches/streaming/inteproxy/proxycore.py
===================================================================
--- branches/streaming/inteproxy/proxycore.py	2012-01-03 16:29:56 UTC (rev 331)
+++ branches/streaming/inteproxy/proxycore.py	2012-01-03 17:31:29 UTC (rev 332)
@@ -299,6 +299,12 @@
 
         return response_message
 
+    def send_headers(self, response):
+        """Write the HTTP headers to the output stream."""
+        for header, value in response.headers.items():
+            self.log_debug("header to client: %s:%r", header, value)
+            self.send_header(header, value)
+        self.end_headers()
 
     def handle_response(self, response):
         # The HTTP version in the reply generated by send_response is
@@ -309,19 +315,16 @@
         self.protocol_version = response.version
         self.send_response(response.status, response.reason)
 
-        for header, value in response.headers.items():
-            self.log_debug("header to client: %s:%r", header, value)
-            self.send_header(header, value)
-        self.end_headers()
-
         do_rewrite = self.have_to_rewrite()
         do_chunked = response.headers.get("Transfer-encoding") == "chunked"
 
         if do_chunked and do_rewrite:
+            self.send_headers(response)
             self.transfer_data_rewrite_chunked(response)
         else:
             if do_rewrite:
                 self.rewrite_urls(response, do_rewrite)
+            self.send_headers(response)
             self.transfer_data(response.read, self.wfile.write,
                                chunked = do_chunked)
 



More information about the Inteproxy-commits mailing list