aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http/http1/read.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-06-01 09:58:01 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-06-01 09:58:01 +1200
commita061e4587772f4a87eb43d84f2ed358f7cc98fbd (patch)
tree1aba05c9d0d6f654fe946897dcb8b5d9127a3de2 /netlib/http/http1/read.py
parent06703542037d1c84b0dcb60c6d1c500a0d189e93 (diff)
parenta7abf8b731658b4e7ed8705f7a94a6a62f08d51d (diff)
downloadmitmproxy-a061e4587772f4a87eb43d84f2ed358f7cc98fbd.tar.gz
mitmproxy-a061e4587772f4a87eb43d84f2ed358f7cc98fbd.tar.bz2
mitmproxy-a061e4587772f4a87eb43d84f2ed358f7cc98fbd.zip
Merge branch 'master' of github.com:cortesi/mitmproxy
Diffstat (limited to 'netlib/http/http1/read.py')
-rw-r--r--netlib/http/http1/read.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/netlib/http/http1/read.py b/netlib/http/http1/read.py
index d30976bd..5783ec67 100644
--- a/netlib/http/http1/read.py
+++ b/netlib/http/http1/read.py
@@ -6,6 +6,19 @@ import re
from ... import utils
from ...exceptions import HttpReadDisconnect, HttpSyntaxException, HttpException, TcpDisconnect
from .. import Request, Response, Headers
+from .. import url
+
+
+def get_header_tokens(headers, key):
+ """
+ Retrieve all tokens for a header key. A number of different headers
+ follow a pattern where each header line can containe comma-separated
+ tokens, and headers can be set multiple times.
+ """
+ if key not in headers:
+ return []
+ tokens = headers[key].split(",")
+ return [token.strip() for token in tokens]
def read_request(rfile, body_size_limit=None):
@@ -147,7 +160,7 @@ def connection_close(http_version, headers):
"""
# At first, check if we have an explicit Connection header.
if "connection" in headers:
- tokens = utils.get_header_tokens(headers, "connection")
+ tokens = get_header_tokens(headers, "connection")
if "close" in tokens:
return True
elif "keep-alive" in tokens:
@@ -240,7 +253,7 @@ def _read_request_line(rfile):
scheme, path = None, None
else:
form = "absolute"
- scheme, host, port, path = utils.parse_url(path)
+ scheme, host, port, path = url.parse(path)
_check_http_version(http_version)
except ValueError: