[Inteproxy-commits] r113 - in trunk: . inteproxy
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Feb 21 16:44:39 CET 2008
Author: bh
Date: 2008-02-21 16:44:39 +0100 (Thu, 21 Feb 2008)
New Revision: 113
Modified:
trunk/ChangeLog
trunk/inteproxy/proxycore.py
Log:
* inteproxy/proxycore.py
(InteProxyHTTPRequestHandler.handle_proxy_request): Handle
urllib2.URLError exceptions raised by urllib2.urlopen. These are
more low-level than the already handled HTTPError exceptions.
This avoids exceptions in cases where the client requests
/favicon.ico from InteProxy using InteProxy directly as a
HTTP-server
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-02-21 15:31:37 UTC (rev 112)
+++ trunk/ChangeLog 2008-02-21 15:44:39 UTC (rev 113)
@@ -1,5 +1,15 @@
2008-02-21 Bernhard Herzog <bh at intevation.de>
+ * inteproxy/proxycore.py
+ (InteProxyHTTPRequestHandler.handle_proxy_request): Handle
+ urllib2.URLError exceptions raised by urllib2.urlopen. These are
+ more low-level than the already handled HTTPError exceptions.
+ This avoids exceptions in cases where the client requests
+ /favicon.ico from InteProxy using InteProxy directly as a
+ HTTP-server
+
+2008-02-21 Bernhard Herzog <bh at intevation.de>
+
Some refactoring
* inteproxy/proxycore.py
Modified: trunk/inteproxy/proxycore.py
===================================================================
--- trunk/inteproxy/proxycore.py 2008-02-21 15:31:37 UTC (rev 112)
+++ trunk/inteproxy/proxycore.py 2008-02-21 15:44:39 UTC (rev 113)
@@ -137,19 +137,27 @@
# Retrieve the url described by the request and pass everything
# through to the client.
#
+ response = None
try:
response = urllib2.urlopen(request)
except urllib2.HTTPError, err:
# a HTTPError is a valid http response object, so we can
# treat it like a normal response.
response = err
+ except urllib2.URLError, err:
+ # a more generic error and probably more low-level error.
+ # Could be an error raised by ProxyHTTPConnection, for
+ # instance. We cannot do much here, so we simply send the
+ # client a 502 (Bad Gateway) error
+ self.send_error(502, str(err))
+ if response is not None:
+ 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("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):
More information about the Inteproxy-commits
mailing list