diff --git a/deproxy.py b/deproxy.py index 53e56b7..f4261a8 100755 --- a/deproxy.py +++ b/deproxy.py @@ -908,7 +908,6 @@ def handle_one_request(self, rfile, wfile): close_connection = True else: close_connection = True - close_connection = True message_chain = None request_id = incoming_request.headers.get(request_id_header_name) @@ -956,7 +955,8 @@ def handle_one_request(self, rfile, wfile): resp = resp[0] if (resp.body is not None and - 'Content-Length' not in resp.headers): + 'Content-Length' not in resp.headers and + resp.headers.get('Transfer-Encoding', '') != 'chunked'): resp.headers.add('Content-Length', len(resp.body)) if add_default_headers: @@ -1066,8 +1066,7 @@ def parse_request(self, rfile, wfile): persistent_connection = False if (version == 'HTTP/1.1' and - 'Connection' in headers and - headers['Connection'] != 'close'): + headers.get('Connection', '') != 'close'): persistent_connection = True logger.debug('reading body')