aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2014-11-07 15:59:00 +1300
committerAldo Cortesi <aldo@nullcube.com>2014-11-07 15:59:00 +1300
commit9ce2f473f6febf3738dca77b20ab9a7d3092d3d0 (patch)
treec32840434fe497e8c3e38e452ced2c2202c4d29e /netlib/http.py
parentba468f12b8f59f63ce85b221f0cb2d9e004efe6e (diff)
downloadmitmproxy-9ce2f473f6febf3738dca77b20ab9a7d3092d3d0.tar.gz
mitmproxy-9ce2f473f6febf3738dca77b20ab9a7d3092d3d0.tar.bz2
mitmproxy-9ce2f473f6febf3738dca77b20ab9a7d3092d3d0.zip
Simplify expected_http_body_size signature, fixing a traceback found in fuzzing
Diffstat (limited to 'netlib/http.py')
-rw-r--r--netlib/http.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/netlib/http.py b/netlib/http.py
index 9268418c..d2fc6343 100644
--- a/netlib/http.py
+++ b/netlib/http.py
@@ -406,8 +406,11 @@ def expected_http_body_size(headers, is_request, request_method, response_code):
"""
Returns the expected body length:
- a positive integer, if the size is known in advance
- - None, if the size in unknown in advance (chunked encoding)
+ - None, if the size in unknown in advance (chunked encoding or invalid
+ data)
- -1, if all data should be read until end of stream.
+
+ May raise HttpError.
"""
# Determine response size according to
# http://tools.ietf.org/html/rfc7230#section-3.3
@@ -429,10 +432,7 @@ def expected_http_body_size(headers, is_request, request_method, response_code):
raise ValueError()
return size
except ValueError:
- raise HttpError(
- 400 if is_request else 502,
- "Invalid content-length header: %s" % headers["content-length"]
- )
+ return None
if is_request:
return 0
return -1