Skip to content

Commit

Permalink
Change signature of getRawHeaders()
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigc committed Sep 22, 2020
1 parent 50ccd1c commit e6f417b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/twisted/web/http_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
Mapping,
Optional,
Sequence,
TypeVar,
Tuple,
Union,
)
from collections.abc import Sequence as _Sequence

Expand Down Expand Up @@ -222,9 +224,11 @@ def addRawHeader(self, name: AnyStr, value: AnyStr) -> None:

self.setRawHeaders(name, values)

_T = TypeVar("_T")

def getRawHeaders(
self, name: AnyStr, default: List[AnyStr] = None
) -> Optional[List[AnyStr]]:
self, name: AnyStr, default: Optional[_T] = None
) -> Union[List[AnyStr], Optional[_T]]:
"""
Returns a list of headers matching the given name as the raw string
given.
Expand All @@ -238,8 +242,8 @@ def getRawHeaders(
values. Otherwise, C{default}.
"""
encodedName = self._encodeName(name)
values = self._rawHeaders.get(encodedName, None)
if values is None:
values = self._rawHeaders.get(encodedName, [])
if not values:
return default

if isinstance(name, str):
Expand Down

0 comments on commit e6f417b

Please sign in to comment.