Split HTTP/2 pseudo-headers from the actual headers and parse them.
(
h2_headers: Sequence[tuple[bytes, bytes]],
)
| 688 | |
| 689 | |
| 690 | def 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__ = [ |
no test coverage detected
searching dependent graphs…