diff options
author | Maximilian Hils <git@maximilianhils.com> | 2013-12-08 01:39:50 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2013-12-08 01:39:50 +0100 |
commit | 64139a1e7ed32f5d995c8fdea0d82c2d2d44f195 (patch) | |
tree | 57f82ac4c4be727098a577f82e9d6a33a4c41e95 /netlib/http.py | |
parent | 390f2a46c920ee332d758d6c46999b5147e0b30b (diff) | |
parent | 7213f86d49960a625643fb6179e6a3731b16d462 (diff) | |
download | mitmproxy-64139a1e7ed32f5d995c8fdea0d82c2d2d44f195.tar.gz mitmproxy-64139a1e7ed32f5d995c8fdea0d82c2d2d44f195.tar.bz2 mitmproxy-64139a1e7ed32f5d995c8fdea0d82c2d2d44f195.zip |
merge origin/master
Diffstat (limited to 'netlib/http.py')
-rw-r--r-- | netlib/http.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/netlib/http.py b/netlib/http.py index f1a2bfb5..7060b688 100644 --- a/netlib/http.py +++ b/netlib/http.py @@ -283,32 +283,23 @@ def parse_init_http(line): return method, url, httpversion -def request_connection_close(httpversion, headers): +def connection_close(httpversion, headers): """ - Checks the request to see if the client connection should be closed. + Checks the message to see if the client connection should be closed according to RFC 2616 Section 8.1 """ + # At first, check if we have an explicit Connection header. if "connection" in headers: toks = get_header_tokens(headers, "connection") if "close" in toks: return True elif "keep-alive" in toks: return False - # HTTP 1.1 connections are assumed to be persistent + # If we don't have a Connection header, HTTP 1.1 connections are assumed to be persistent if httpversion == (1, 1): return False return True -def response_connection_close(httpversion, headers): - """ - Checks the response to see if the client connection should be closed. - """ - if request_connection_close(httpversion, headers): - return True - elif (not has_chunked_encoding(headers)) and "content-length" in headers: - return False - return True - def read_http_body_request(rfile, wfile, headers, httpversion, limit): """ |