MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / normalize_h1_headers

Function normalize_h1_headers

mitmproxy/proxy/layers/http/_http2.py:340–352  ·  view source on GitHub ↗
(
    headers: list[tuple[bytes, bytes]], is_client: bool
)

Source from the content-addressed store, hash-verified

338
339
340def normalize_h1_headers(
341 headers: list[tuple[bytes, bytes]], is_client: bool
342) -> list[tuple[bytes, bytes]]:
343 # HTTP/1 servers commonly send capitalized headers (Content-Length vs content-length),
344 # which isn't valid HTTP/2. As such we normalize.
345 # Make sure that this is not just an iterator but an iterable,
346 # otherwise hyper-h2 will silently drop headers.
347 return list(
348 h2.utilities.normalize_outbound_headers(
349 headers,
350 h2.utilities.HeaderValidationFlags(is_client, False, not is_client, False),
351 )
352 )
353
354
355def normalize_h2_headers(headers: list[tuple[bytes, bytes]]) -> CommandGenerator[None]:

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…