[Inteproxy-commits] r112 - in trunk: . inteproxy
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Feb 21 16:31:37 CET 2008
Author: bh
Date: 2008-02-21 16:31:37 +0100 (Thu, 21 Feb 2008)
New Revision: 112
Modified:
trunk/ChangeLog
trunk/inteproxy/proxycore.py
Log:
Some refactoring
* inteproxy/proxycore.py
(InteProxyHTTPRequestHandler.handle_proxy_request)
(InteProxyHTTPRequestHandler.handle_response): Move some of the
response handling code in handle_proxy_request into the new method
handle_response
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-02-14 16:22:24 UTC (rev 111)
+++ trunk/ChangeLog 2008-02-21 15:31:37 UTC (rev 112)
@@ -1,3 +1,13 @@
+2008-02-21 Bernhard Herzog <bh at intevation.de>
+
+ Some refactoring
+
+ * inteproxy/proxycore.py
+ (InteProxyHTTPRequestHandler.handle_proxy_request)
+ (InteProxyHTTPRequestHandler.handle_response): Move some of the
+ response handling code in handle_proxy_request into the new method
+ handle_response
+
2008-02-14 Bernhard Herzog <bh at intevation.de>
Implement http basic auth
Modified: trunk/inteproxy/proxycore.py
===================================================================
--- trunk/inteproxy/proxycore.py 2008-02-14 16:22:24 UTC (rev 111)
+++ trunk/inteproxy/proxycore.py 2008-02-21 15:31:37 UTC (rev 112)
@@ -143,12 +143,32 @@
# a HTTPError is a valid http response object, so we can
# treat it like a normal response.
response = err
+
self.log_debug("received response: %s: %r", response.code,
response.msg)
-
# check for fees and access constraints and run a dialog
response_read = handle_fees_and_access_constraints(remote_url, response)
+ self.handle_response(response, response_read)
+ self.log_debug("request finished")
+
+ def read_client_request(self):
+ """Read the client request including the body, if any.
+ The request is returned as a TranscoderRequest instance."""
+ body = None
+ length = int(self.headers.getheader("Content-Length", "0"))
+ if length:
+ # FIXME: check whether length bytes were read
+ body = self.rfile.read(length)
+ self.log_debug("body of client request (%d bytes):\n%r",
+ length, data)
+ else:
+ self.log_debug("client request has no body")
+
+ return inteproxy.transcoder.TranscoderRequest(self.command, self.path,
+ self.headers, body)
+
+ def handle_response(self, response, response_read):
# 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
@@ -175,24 +195,7 @@
transfer_encoding = response.info().get("Transfer-encoding")
self.transfer_data(response_read, self.wfile.write,
chunked = (transfer_encoding == "chunked"))
- self.log_debug("request finished")
- def read_client_request(self):
- """Read the client request including the body, if any.
- The request is returned as a TranscoderRequest instance."""
- body = None
- length = int(self.headers.getheader("Content-Length", "0"))
- if length:
- # FIXME: check whether length bytes were read
- body = self.rfile.read(length)
- self.log_debug("body of client request (%d bytes):\n%r",
- length, data)
- else:
- self.log_debug("client request has no body")
-
- return inteproxy.transcoder.TranscoderRequest(self.command, self.path,
- self.headers, body)
-
def transfer_data(self, read, write, length=None, chunked=False):
"""Transfer data from one 'file' to another in chunks
More information about the Inteproxy-commits
mailing list