backend/wsgi/wsgiRequest.py | 7 ++++--- proxy/proxy/apacheHandler.py | 10 +--------- 2 files changed, 5 insertions(+), 12 deletions(-)
New commits: commit 15b32d1fdc2fbd3a6671eef47855b22d2d1f6684 Author: Miroslav Suchý msuchy@redhat.com Date: Wed May 11 17:23:13 2011 +0200
695651 - mimic req.connection.local_addr from mod_python
addressing: [Wed May 11 14:56:49 2011] [error] Traceback (most recent call last): [Wed May 11 14:56:49 2011] [error] File "/usr/share/rhn/proxy/apacheServer.py", line 66, in __call__ [Wed May 11 14:56:49 2011] [error] ret = f(req) [Wed May 11 14:56:49 2011] [error] File "/usr/share/rhn/proxy/apacheHandler.py", line 105, in headerParserHandler [Wed May 11 14:56:49 2011] [error] ret = self._transformKickstartRequest(req) [Wed May 11 14:56:49 2011] [error] File "/usr/share/rhn/proxy/apacheHandler.py", line 137, in _transformKickstartRequest [Wed May 11 14:56:49 2011] [error] return self._transformKickstartRequestForBroker(req) [Wed May 11 14:56:49 2011] [error] File "/usr/share/rhn/proxy/apacheHandler.py", line 149, in _transformKickstartRequestForBroker [Wed May 11 14:56:49 2011] [error] (status, checksum) = self._querySatelliteForChecksum(req) [Wed May 11 14:56:49 2011] [error] File "/usr/share/rhn/proxy/apacheHandler.py", line 226, in _querySatelliteForChecksum [Wed May 11 14:56:49 2011] [error] port = req.connection.local_addr[1] [Wed May 11 14:56:49 2011] [error] AttributeError: WsgiConnection instance has no attribute 'local_addr'
diff --git a/backend/wsgi/wsgiRequest.py b/backend/wsgi/wsgiRequest.py index fe37d54..d57143a 100644 --- a/backend/wsgi/wsgiRequest.py +++ b/backend/wsgi/wsgiRequest.py @@ -29,7 +29,7 @@ class WsgiRequest: self.start_response = start_response self.uri = self.unparsed_uri = env['REQUEST_URI'] self.server = WsgiServer(env['SERVER_NAME'], env['SERVER_PORT']) - self.connection = WsgiConnection(env['REMOTE_ADDR']) + self.connection = WsgiConnection(env) self.options = {} self.main = 0 self.proto_num = float(env['SERVER_PROTOCOL'].split('/')[1]) @@ -95,8 +95,9 @@ class WsgiServer: self.port = int(port)
class WsgiConnection: - def __init__(self, remote_ip): - self.remote_ip = remote_ip + def __init__(self, env): + self.remote_ip = env['REMOTE_ADDR'] + self.local_addr = (env['SERVER_NAME'], env['SERVER_PORT'])
class WsgiMPtable: """ This class emulates mod_python's mp_table. See
commit 4ac751a7ef3112b3d45fefde183949bb11af2150 Author: Miroslav Suchý msuchy@redhat.com Date: Wed May 11 17:07:29 2011 +0200
695651 - is_virtual is not exposed in mod_wsgi
we do not need it anyway. Decission base on req.server.port should be enough
addressing: [Wed May 11 14:21:31 2011] [error] Traceback (most recent call last): [Wed May 11 14:21:31 2011] [error] File "/usr/share/rhn/proxy/apacheServer.py", line 66, in __call__ [Wed May 11 14:21:31 2011] [error] ret = f(req) [Wed May 11 14:21:31 2011] [error] File "/usr/share/rhn/proxy/apacheHandler.py", line 105, in headerParserHandler [Wed May 11 14:21:31 2011] [error] ret = self._transformKickstartRequest(req) [Wed May 11 14:21:31 2011] [error] File "/usr/share/rhn/proxy/apacheHandler.py", line 137, in _transformKickstartRequest [Wed May 11 14:21:31 2011] [error] return self._transformKickstartRequestForBroker(req) [Wed May 11 14:21:31 2011] [error] File "/usr/share/rhn/proxy/apacheHandler.py", line 149, in _transformKickstartRequestForBroker [Wed May 11 14:21:31 2011] [error] (status, checksum) = self._querySatelliteForChecksum(req) [Wed May 11 14:21:31 2011] [error] File "/usr/share/rhn/proxy/apacheHandler.py", line 210, in _querySatelliteForChecksum [Wed May 11 14:21:31 2011] [error] if req.server.is_virtual and req.server.port == 443: [Wed May 11 14:21:31 2011] [error] AttributeError: WsgiServer instance has no attribute 'is_virtual'
diff --git a/proxy/proxy/apacheHandler.py b/proxy/proxy/apacheHandler.py index 4c358c2..c5a3178 100644 --- a/proxy/proxy/apacheHandler.py +++ b/proxy/proxy/apacheHandler.py @@ -202,16 +202,8 @@ class apacheHandler(rhnApache): is OK, and a checksum is not returned, the old BZ 158236 behavior will be used. """ - - # There isn't an easy way from within mod_python to definitely - # determine which scheme was used to contact us, so we'll attempt to - # use some heuristics. If a virtual server fielded the request and - # the port number is 443, we can probably assume it's HTTPS. Since - # we're just making a connection to localhost, it's not the end of the - # world if we get it wrong. - scheme = SCHEME_HTTP - if req.server.is_virtual and req.server.port == 443: + if req.server.port == 443: scheme = SCHEME_HTTPS log_debug(6, "Using scheme: %s" % scheme)