MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / format_h2_request_headers

Function format_h2_request_headers

mitmproxy/proxy/layers/http/_http2.py:364–387  ·  view source on GitHub ↗
(
    context: Context,
    event: RequestHeaders,
)

Source from the content-addressed store, hash-verified

362
363
364def format_h2_request_headers(
365 context: Context,
366 event: RequestHeaders,
367) -> CommandGenerator[list[tuple[bytes, bytes]]]:
368 pseudo_headers = [
369 (b":method", event.request.data.method),
370 (b":scheme", event.request.data.scheme),
371 (b":path", event.request.data.path),
372 ]
373 if event.request.authority:
374 pseudo_headers.append((b":authority", event.request.data.authority))
375
376 if event.request.is_http2 or event.request.is_http3:
377 hdrs = list(event.request.headers.fields)
378 if context.options.normalize_outbound_headers:
379 yield from normalize_h2_headers(hdrs)
380 else:
381 headers = event.request.headers
382 if not event.request.authority and "host" in headers:
383 headers = headers.copy()
384 pseudo_headers.append((b":authority", headers.pop(b"host")))
385 hdrs = normalize_h1_headers(list(headers.fields), True)
386
387 return pseudo_headers + hdrs
388
389
390def format_h2_response_headers(

Callers 2

_handle_event2Method · 0.85
_handle_eventMethod · 0.85

Calls 5

normalize_h2_headersFunction · 0.85
normalize_h1_headersFunction · 0.85
appendMethod · 0.45
copyMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…