|
1 | | -from typing import Any, Iterator, Optional, Protocol, Tuple, runtime_checkable |
2 | | - |
3 | | - |
4 | | -class Headers(Protocol): |
5 | | - """ |
6 | | - A case-insensitive mapping of HTTP response headers. |
7 | | -
|
8 | | - Header name lookups are case-insensitive per RFC 7230, so |
9 | | - ``headers.get('content-type')`` and ``headers.get('Content-Type')`` |
10 | | - return the same value. The concrete type returned depends on the HTTP |
11 | | - backend in use and should not be relied upon directly. |
12 | | - """ |
13 | | - |
14 | | - def get(self, key: str, default: Any = None) -> Any: |
15 | | - """Return the value for *key* (case-insensitive), or *default*.""" |
16 | | - ... |
17 | | - |
18 | | - def __getitem__(self, key: str) -> Any: ... |
19 | | - |
20 | | - def __contains__(self, key: object) -> bool: ... |
21 | | - |
22 | | - def __iter__(self) -> Iterator[str]: ... |
23 | | - |
24 | | - def items(self) -> Any: ... |
| 1 | +from collections.abc import Mapping |
| 2 | +from typing import Any, Optional, Protocol, runtime_checkable |
| 3 | + |
| 4 | +Headers = Mapping[str, Any] |
| 5 | +""" |
| 6 | +A case-insensitive mapping of HTTP response headers. |
| 7 | +
|
| 8 | +Header name lookups are case-insensitive per RFC 7230, so |
| 9 | +``headers.get('content-type')`` and ``headers.get('Content-Type')`` |
| 10 | +return the same value. The concrete type returned depends on the HTTP |
| 11 | +backend in use and should not be relied upon directly. |
| 12 | +""" |
25 | 13 |
|
26 | 14 |
|
27 | 15 | @runtime_checkable |
|
0 commit comments