1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00

Add headers in proxy server response

This commit is contained in:
Samuel Fekete
2017-11-03 11:07:23 +00:00
committed by Samuel Fekete
parent 06dc2190d6
commit 4b6b5effc7

View File

@@ -19,10 +19,15 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
'''
Simple proxy server.
(from: http://effbot.org/librarybook/simplehttpserver.htm).
(Inspired by: http://effbot.org/librarybook/simplehttpserver.htm).
'''
def do_GET(self):
self.copyfile(urlopen(self.path), self.wfile)
upstream_response = urlopen(self.path)
self.send_response(upstream_response.status, upstream_response.msg)
for header in upstream_response.headers.items():
self.send_header(*header)
self.end_headers()
self.copyfile(upstream_response, self.wfile)
@pytest.yield_fixture(scope='session')