[Inteproxy-commits] r26 - trunk

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 8 17:25:23 CET 2007


Author: bh
Date: 2007-02-08 17:25:23 +0100 (Thu, 08 Feb 2007)
New Revision: 26

Modified:
   trunk/ChangeLog
   trunk/InteProxy.py
Log:
* InteProxy.py (InteProxyHTTPRequestHandler.handle_proxy_request):
Set the protocol version of the InteProxyHTTPRequestHandler to the
version used in the request.  Ideally it should be set to the
version of the reply received from the remote host.  But that's
not possible to implement with urllib2.  See the comments in the
code. Fixes issue #271.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-02-08 12:35:08 UTC (rev 25)
+++ trunk/ChangeLog	2007-02-08 16:25:23 UTC (rev 26)
@@ -1,9 +1,18 @@
 2007-02-08  Bernhard Herzog  <bh at intevation.de>
 
+	* InteProxy.py (InteProxyHTTPRequestHandler.handle_proxy_request):
+	Set the protocol version of the InteProxyHTTPRequestHandler to the
+	version used in the request.  Ideally it should be set to the
+	version of the reply received from the remote host.  But that's
+	not possible to implement with urllib2.  See the comments in the
+	code. Fixes issue #271.
+
+2007-02-08  Bernhard Herzog  <bh at intevation.de>
+
 	* InteProxy.py (run_server): New option --workers to specify the
 	number of the worker threads.  Default is 5.  run_server now
 	starts the requested number of threads.
- 
+
 	* getpassword.py (get_password_with_cache): Access the password
 	cache in a thread-safe way.
 

Modified: trunk/InteProxy.py
===================================================================
--- trunk/InteProxy.py	2007-02-08 12:35:08 UTC (rev 25)
+++ trunk/InteProxy.py	2007-02-08 16:25:23 UTC (rev 26)
@@ -168,7 +168,25 @@
             response = err
         self.log_debug("received response: %s: %r", response.code,
                        response.msg)
+
+        # Ideally, the HTTP version in our reply to the client should be
+        # what the remote server used in its reply.  Unfortunately,
+        # there doesn't seem to be a way to get that information from
+        # urllib2.  So we pretend that the reply uses the same version
+        # as the request we got from the client.
+        #
+        # If we do not set the version of the reply,
+        # BaseHTTPRequestHandler will use HTTP/1.0 which can lead to
+        # problems if the real version is HTTP/1.1, because the server
+        # might send the data using the chunked transfer encoding which
+        # not alled in HTTP/1.0.  Some clients, including Firefox 1.5,
+        # produce errors in that case.
+        #
+        # The HTTP version in the reply generated by send_response is
+        # taken from self.protocol_version.
+        self.protocol_version = self.request_version
         self.send_response(response.code, response.msg)
+
         for header, value in response.info().items():
             self.log_debug("received header: %s:%r", header, value)
             self.send_header(header, value)



More information about the Inteproxy-commits mailing list