diff --git a/warcprox/mitmproxy.py b/warcprox/mitmproxy.py index 1b7dcbd..6d87470 100644 --- a/warcprox/mitmproxy.py +++ b/warcprox/mitmproxy.py @@ -465,13 +465,15 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler): buf = prox_rec_res.read(65536) while buf != b'': buf = prox_rec_res.read(65536) - if self._max_resource_size: - if prox_rec_res.recorder.len > self._max_resource_size: - prox_rec_res.truncated = b'length' - self.logger.error( - 'Max resource size %d bytes exceeded for URL %s', + if (self._max_resource_size and + prox_rec_res.recorder.len > self._max_resource_size): + prox_rec_res.truncated = b'length' + self._remote_server_conn.sock.close() + self.logger.info( + 'truncating response because max resource size %d ' + 'bytes exceeded for URL %s', self._max_resource_size, self.url) - break + break self.log_request(prox_rec_res.status, prox_rec_res.recorder.len) # Let's close off the remote end. If remote connection is fine,