diff --git a/netlib/http/headers.py b/netlib/http/headers.py index 2caf8d519..6067ff5e5 100644 --- a/netlib/http/headers.py +++ b/netlib/http/headers.py @@ -76,7 +76,7 @@ class Headers(MultiDict): For use with the "Set-Cookie" header, see :py:meth:`get_all`. """ - def __init__(self, fields=None, **headers): + def __init__(self, fields=(), **headers): """ Args: fields: (optional) list of ``(name, value)`` header byte tuples, diff --git a/netlib/http/request.py b/netlib/http/request.py index 5a528bf21..a6e2a5efb 100644 --- a/netlib/http/request.py +++ b/netlib/http/request.py @@ -19,7 +19,7 @@ host_header_re = re.compile(r"^(?P[^:]+|\[.+\])(?::(?P\d+))?$") class RequestData(MessageData): - def __init__(self, first_line_format, method, scheme, host, port, path, http_version, headers=None, content=None, + def __init__(self, first_line_format, method, scheme, host, port, path, http_version, headers=(), content=None, timestamp_start=None, timestamp_end=None): if not isinstance(headers, Headers): headers = Headers(headers) diff --git a/netlib/http/response.py b/netlib/http/response.py index 7d272e104..a6a5bf474 100644 --- a/netlib/http/response.py +++ b/netlib/http/response.py @@ -11,7 +11,7 @@ from .. import utils class ResponseData(MessageData): - def __init__(self, http_version, status_code, reason=None, headers=None, content=None, + def __init__(self, http_version, status_code, reason=None, headers=(), content=None, timestamp_start=None, timestamp_end=None): if not isinstance(headers, Headers): headers = Headers(headers) diff --git a/test/mitmproxy/test_flow_export.py b/test/mitmproxy/test_flow_export.py index 0374ba7d8..af3713de3 100644 --- a/test/mitmproxy/test_flow_export.py +++ b/test/mitmproxy/test_flow_export.py @@ -22,7 +22,7 @@ def python_equals(testdata, text): req_get = lambda: netlib.tutils.treq(method='GET', content='', path=b"/path?a=foo&a=bar&b=baz") -req_post = lambda: netlib.tutils.treq(method='POST', headers=None) +req_post = lambda: netlib.tutils.treq(method='POST', headers=()) req_patch = lambda: netlib.tutils.treq(method='PATCH', path=b"/path?query=param") diff --git a/test/netlib/http/http2/test_connections.py b/test/netlib/http/http2/test_connections.py index 9312576f0..139d4fc15 100644 --- a/test/netlib/http/http2/test_connections.py +++ b/test/netlib/http/http2/test_connections.py @@ -460,7 +460,7 @@ class TestAssembleRequest(object): b'', b'/', b"HTTP/2.0", - None, + (), None, )) assert len(bytes) == 1 @@ -475,7 +475,7 @@ class TestAssembleRequest(object): b'', b'/', b"HTTP/2.0", - None, + (), None, ) req.stream_id = 0x42 diff --git a/test/netlib/http/test_request.py b/test/netlib/http/test_request.py index fae7aefe5..c03db3393 100644 --- a/test/netlib/http/test_request.py +++ b/test/netlib/http/test_request.py @@ -13,7 +13,7 @@ class TestRequestData(object): with raises(ValueError): treq(headers="foobar") - assert isinstance(treq(headers=None).headers, Headers) + assert isinstance(treq(headers=()).headers, Headers) class TestRequestCore(object): diff --git a/test/netlib/http/test_response.py b/test/netlib/http/test_response.py index 63c976a26..5eac2a15f 100644 --- a/test/netlib/http/test_response.py +++ b/test/netlib/http/test_response.py @@ -15,7 +15,7 @@ class TestResponseData(object): with raises(ValueError): tresp(headers="foobar") - assert isinstance(tresp(headers=None).headers, Headers) + assert isinstance(tresp(headers=()).headers, Headers) class TestResponseCore(object):