From 9ce2f473f6febf3738dca77b20ab9a7d3092d3d0 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 7 Nov 2014 15:59:00 +1300 Subject: Simplify expected_http_body_size signature, fixing a traceback found in fuzzing --- netlib/http.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'netlib/http.py') 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 -- cgit v1.2.3