diff --git a/httpx/_models.py b/httpx/_models.py index 7a3b5885..84739f74 100644 --- a/httpx/_models.py +++ b/httpx/_models.py @@ -3,7 +3,7 @@ import email.message import json as jsonlib import typing import urllib.request -from collections.abc import MutableMapping +from collections.abc import Mapping, MutableMapping from http.cookiejar import Cookie, CookieJar from ._content import ByteStream, UnattachedStream, encode_request, encode_response @@ -65,7 +65,7 @@ class Headers(typing.MutableMapping[str, str]): self._list = [] # type: typing.List[typing.Tuple[bytes, bytes, bytes]] elif isinstance(headers, Headers): self._list = list(headers._list) - elif isinstance(headers, dict): + elif isinstance(headers, Mapping): self._list = [ ( normalize_header_key(k, lower=False, encoding=encoding), diff --git a/httpx/_types.py b/httpx/_types.py index 784848ef..8a50314b 100644 --- a/httpx/_types.py +++ b/httpx/_types.py @@ -43,8 +43,8 @@ QueryParamTypes = Union[ HeaderTypes = Union[ "Headers", - Dict[str, str], - Dict[bytes, bytes], + Mapping[str, str], + Mapping[bytes, bytes], Sequence[Tuple[str, str]], Sequence[Tuple[bytes, bytes]], ]