Commit 14b9e0ad authored by Jérome Perrin's avatar Jérome Perrin

software/caddy-frontend/test: use resource.Session as context manager

this prevents ResourceWarning because this way the sockets are closed
parent 03c55402
......@@ -499,6 +499,7 @@ def fakeHTTPSResult(domain, path, port=HTTPS_PORT,
headers.setdefault('Via', 'http/1.1 clientvia')
session = requests.Session()
with session:
if source_ip is not None:
new_source = source.SourceAddressAdapter(source_ip)
session.mount('http://', new_source)
......@@ -541,6 +542,7 @@ def fakeHTTPResult(domain, path, port=HTTP_PORT,
headers.setdefault('Via', 'http/1.1 clientvia')
headers['Host'] = '%s:%s' % (domain, port)
session = requests.Session()
with session:
if source_ip is not None:
new_source = source.SourceAddressAdapter(source_ip)
session.mount('http://', new_source)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment