from __future__ import annotations
import typing
from eggfetch.compat.httpx._headers import Headers as _BaseHeaders
if typing.TYPE_CHECKING:
from collections.abc import Mapping
class Headers(_BaseHeaders):
def __or__(self, other: Mapping[str, str]) -> Headers:
if not isinstance(other, typing.Mapping):
try:
from collections.abc import Mapping as _Mapping
if not isinstance(other, _Mapping):
return NotImplemented
except Exception:
return NotImplemented
merged = self.copy()
wrapped = Headers(encoding=merged.encoding)
wrapped._items = list(merged._items)
wrapped.update(other)
return wrapped
def __ror__(self, other: Mapping[str, str]) -> Headers:
from collections.abc import Mapping as _Mapping
if not isinstance(other, _Mapping):
return NotImplemented
merged = Headers(other)
merged.update(self)
return merged
def __ior__(self, other) -> Headers:
self.update(other)
return self
__all__ = ["Headers"]