From 0f2654ffd4ff82f5b60c3e093fb4e2b8fffbea07 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 16 Jun 2015 20:56:00 +0300 Subject: [PATCH 1/3] Remove unconditonal connection close (it was mistake?). --- deproxy.py | 1 - 1 file changed, 1 deletion(-) diff --git a/deproxy.py b/deproxy.py index 53e56b7..f48b5ba 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) From ee5b5961a57e383edeb2c24c08e7df30d7daae61 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 16 Jun 2015 20:56:36 +0300 Subject: [PATCH 2/3] Don't set Content-Length if encoding is chunked. --- deproxy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deproxy.py b/deproxy.py index f48b5ba..1b829bc 100755 --- a/deproxy.py +++ b/deproxy.py @@ -955,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: From 5c7cb133a04b448fcfb2938307b3de60c4bb75cd Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 16 Jun 2015 20:57:01 +0300 Subject: [PATCH 3/3] With HTTP/1.1 Connection header is not required. --- deproxy.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deproxy.py b/deproxy.py index 1b829bc..f4261a8 100755 --- a/deproxy.py +++ b/deproxy.py @@ -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')