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

Function split_pseudo_headers

mitmproxy/proxy/layers/http/_http2.py:640–657  ·  view source on GitHub ↗
(
    h2_headers: Sequence[tuple[bytes, bytes]],
)

Source from the content-addressed store, hash-verified

638
639
640def split_pseudo_headers(
641 h2_headers: Sequence[tuple[bytes, bytes]],
642) -> tuple[dict[bytes, bytes], http.Headers]:
643 pseudo_headers: dict[bytes, bytes] = {}
644 i = 0
645 for header, value in h2_headers:
646 if header.startswith(b":"):
647 if header in pseudo_headers:
648 raise ValueError(f"Duplicate HTTP/2 pseudo header: {header!r}")
649 pseudo_headers[header] = value
650 i += 1
651 else:
652 # Pseudo-headers must be at the start, we are done here.
653 break
654
655 headers = http.Headers(h2_headers[i:])
656
657 return pseudo_headers, headers
658
659
660def parse_h2_request_headers(

Callers 4

parse_h2_request_headersFunction · 0.85

Calls

no outgoing calls

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…