MCPcopy
hub / github.com/encode/httpx / _normalize_header_value

Function _normalize_header_value

httpx/_models.py:74–82  ·  view source on GitHub ↗

Coerce str/bytes into a strictly byte-wise HTTP header value.

(value: str | bytes, encoding: str | None = None)

Source from the content-addressed store, hash-verified

72
73
74def _normalize_header_value(value: str | bytes, encoding: str | None = None) -> bytes:
75 """
76 Coerce str/bytes into a strictly byte-wise HTTP header value.
77 """
78 if isinstance(value, bytes):
79 return value
80 if not isinstance(value, str):
81 raise TypeError(f"Header value must be str or bytes, not {type(value)}")
82 return value.encode(encoding or "ascii")
83
84
85def _parse_content_type_charset(content_type: str) -> str | None:

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected