Skip to content

Commit

Permalink
Switch from localhost to 127.0.0.1 with prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed May 15, 2024
1 parent 203255e commit e691c81
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions test/test_capture_http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def handle_error(self, request, client_address):
print(f"port: {cls.port}", flush=True)

cls.proxies = {
'https': 'http://localhost:' + str(cls.port),
'http': 'http://localhost:' + str(cls.port),
'https': 'http://127.0.0.1:' + str(cls.port),
'http': 'http://127.0.0.1:' + str(cls.port),
}

print(f"proxies: {cls.proxies}", flush=True)
Expand All @@ -58,12 +58,12 @@ def test_capture_http_proxy(self):
assert response.rec_type == 'response'
assert response.rec_headers['WARC-Target-URI'] == "http://example.com/test"
assert response.content_stream().read().decode('utf-8') == 'Proxied: /http://example.com/test'
assert response.rec_headers['WARC-Proxy-Host'] == 'http://localhost:{0}'.format(self.port)
assert response.rec_headers['WARC-Proxy-Host'] == 'http://127.0.0.1:{0}'.format(self.port)

request = next(ai)
assert request.rec_type == 'request'
assert request.rec_headers['WARC-Target-URI'] == "http://example.com/test"
assert request.rec_headers['WARC-Proxy-Host'] == 'http://localhost:{0}'.format(self.port)
assert request.rec_headers['WARC-Proxy-Host'] == 'http://127.0.0.1:{0}'.format(self.port)

with raises(StopIteration):
assert next(ai)
Expand All @@ -83,29 +83,29 @@ def test_capture_https_proxy(self):
response = next(ai)
assert response.rec_type == 'response'
assert response.rec_headers['WARC-Target-URI'] == "https://example.com/test"
assert response.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert response.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)
assert response.content_stream().read().decode('utf-8') == 'Proxied: /https://example.com/test'

request = next(ai)
assert request.rec_type == 'request'
assert request.rec_headers['WARC-Target-URI'] == "https://example.com/test"
assert request.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert request.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)

response = next(ai)
assert response.rec_type == 'response'
assert response.rec_headers['WARC-Target-URI'] == "https://example.com/foo"
assert response.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert response.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)
assert response.content_stream().read().decode('utf-8') == 'Proxied: /https://example.com/foo'

request = next(ai)
assert request.rec_type == 'request'
assert request.rec_headers['WARC-Target-URI'] == "https://example.com/foo"
assert request.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert request.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)

response = next(ai)
assert response.rec_type == 'response'
assert response.rec_headers['WARC-Target-URI'] == "https://example.com/bar"
assert response.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert response.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)
assert response.content_stream().read().decode('utf-8') == 'Proxied: /https://example.com/bar'

request = next(ai)
Expand All @@ -130,29 +130,29 @@ def test_capture_https_proxy_same_session(self):
response = next(ai)
assert response.rec_type == 'response'
assert response.rec_headers['WARC-Target-URI'] == "https://example.com/test"
assert response.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert response.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)
assert response.content_stream().read().decode('utf-8') == 'Proxied: /https://example.com/test'

request = next(ai)
assert request.rec_type == 'request'
assert request.rec_headers['WARC-Target-URI'] == "https://example.com/test"
assert request.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert request.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)

response = next(ai)
assert response.rec_type == 'response'
assert response.rec_headers['WARC-Target-URI'] == "https://example.com/foo"
assert response.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert response.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)
assert response.content_stream().read().decode('utf-8') == 'Proxied: /https://example.com/foo'

request = next(ai)
assert request.rec_type == 'request'
assert request.rec_headers['WARC-Target-URI'] == "https://example.com/foo"
assert request.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert request.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)

response = next(ai)
assert response.rec_type == 'response'
assert response.rec_headers['WARC-Target-URI'] == "https://example.com/skip"
assert response.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert response.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)
assert response.content_stream().read().decode('utf-8') == 'Proxied: /https://example.com/skip'

request = next(ai)
Expand All @@ -161,7 +161,7 @@ def test_capture_https_proxy_same_session(self):
response = next(ai)
assert response.rec_type == 'response'
assert response.rec_headers['WARC-Target-URI'] == "https://example.com/bar"
assert response.rec_headers['WARC-Proxy-Host'] == 'https://localhost:{0}'.format(self.port)
assert response.rec_headers['WARC-Proxy-Host'] == 'https://127.0.0.1:{0}'.format(self.port)
assert response.content_stream().read().decode('utf-8') == 'Proxied: /https://example.com/bar'

request = next(ai)
Expand Down

0 comments on commit e691c81

Please sign in to comment.