From ff7dd06f4730041db3a9b864d6721a59dffaa94a Mon Sep 17 00:00:00 2001 From: Samuel Fekete Date: Fri, 3 Nov 2017 11:39:13 +0000 Subject: [PATCH] fix proxy for Python 2 --- tests/integration/test_proxy.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_proxy.py b/tests/integration/test_proxy.py index a1fc003..5dfd285 100644 --- a/tests/integration/test_proxy.py +++ b/tests/integration/test_proxy.py @@ -23,8 +23,15 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): ''' def do_GET(self): upstream_response = urlopen(self.path) - self.send_response(upstream_response.status, upstream_response.msg) - for header in upstream_response.headers.items(): + try: + status = upstream_response.status + headers = upstream_response.headers.items() + except AttributeError: + # In Python 2 the response is an addinfourl instance. + status = upstream_response.code + headers = upstream_response.info().items() + self.send_response(status, upstream_response.msg) + for header in headers: self.send_header(*header) self.end_headers() self.copyfile(upstream_response, self.wfile)