mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
close connection when truncating response
This commit is contained in:
parent
595e819961
commit
7ef0612fa6
@ -465,13 +465,15 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
|||||||
buf = prox_rec_res.read(65536)
|
buf = prox_rec_res.read(65536)
|
||||||
while buf != b'':
|
while buf != b'':
|
||||||
buf = prox_rec_res.read(65536)
|
buf = prox_rec_res.read(65536)
|
||||||
if self._max_resource_size:
|
if (self._max_resource_size and
|
||||||
if prox_rec_res.recorder.len > self._max_resource_size:
|
prox_rec_res.recorder.len > self._max_resource_size):
|
||||||
prox_rec_res.truncated = b'length'
|
prox_rec_res.truncated = b'length'
|
||||||
self.logger.error(
|
self._remote_server_conn.sock.close()
|
||||||
'Max resource size %d bytes exceeded for URL %s',
|
self.logger.info(
|
||||||
|
'truncating response because max resource size %d '
|
||||||
|
'bytes exceeded for URL %s',
|
||||||
self._max_resource_size, self.url)
|
self._max_resource_size, self.url)
|
||||||
break
|
break
|
||||||
|
|
||||||
self.log_request(prox_rec_res.status, prox_rec_res.recorder.len)
|
self.log_request(prox_rec_res.status, prox_rec_res.recorder.len)
|
||||||
# Let's close off the remote end. If remote connection is fine,
|
# Let's close off the remote end. If remote connection is fine,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user