diff --git a/mandaye/filters/default.py b/mandaye/filters/default.py index 99facfb..9caf646 100644 --- a/mandaye/filters/default.py +++ b/mandaye/filters/default.py @@ -36,12 +36,14 @@ class MandayeFilter(object): cookie['domain'] = re.sub('^\.*%s$' % (target.hostname), src_hostname, cookie['domain']) # Modify headers + if response.headers.has_key('location'): + response.headers.addheader('location', + re.sub(r'http(s*)://%s' % env["target"].hostname, + r"%s://%s" % (env["mandaye.scheme"], env["HTTP_HOST"]), + response.headers.getheader('location'), + flags=re.IGNORECASE) + ) blacklist = ['transfer-encoding', 'content-length'] - for key, value in response.headers.iteritems(): - if key == 'location': - location = value[0].replace(target.geturl(), - "%s://%s" % (env['mandaye.scheme'], env["HTTP_HOST"])) - response.headers['location'] = [location] for name in blacklist: if response.headers.has_key(name): del response.headers[name] diff --git a/mandaye/response.py b/mandaye/response.py index c4fc03a..3776544 100644 --- a/mandaye/response.py +++ b/mandaye/response.py @@ -48,7 +48,7 @@ def _get_traceback(): return tb_str def _302(location, cookies=None): - headers = HTTPHeader({'Location': [location], + headers = HTTPHeader({'location': [location], 'Content-Type': ['text/html']}) msg = "Reload the page to get source for: %s" % location logger.info('302 redirect to %s' % location)