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

Function parse_h2_response_headers

mitmproxy/proxy/layers/http/_http2.py:690–704  ·  view source on GitHub ↗

Split HTTP/2 pseudo-headers from the actual headers and parse them.

(
    h2_headers: Sequence[tuple[bytes, bytes]],
)

Source from the content-addressed store, hash-verified

688
689
690def parse_h2_response_headers(
691 h2_headers: Sequence[tuple[bytes, bytes]],
692) -> tuple[int, http.Headers]:
693 """Split HTTP/2 pseudo-headers from the actual headers and parse them."""
694 pseudo_headers, headers = split_pseudo_headers(h2_headers)
695
696 try:
697 status_code: int = int(pseudo_headers.pop(b":status"))
698 except KeyError as e:
699 raise ValueError(f"Required pseudo header is missing: {e}")
700
701 if pseudo_headers:
702 raise ValueError(f"Unknown pseudo headers: {pseudo_headers}")
703
704 return status_code, headers
705
706
707__all__ = [

Callers 2

handle_h2_eventMethod · 0.85
parse_headersMethod · 0.85

Calls 2

split_pseudo_headersFunction · 0.85
popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…