MCPcopy Create free account
hub / github.com/encode/httpx / format_request_headers

Function format_request_headers

httpx/_main.py:116–126  ·  view source on GitHub ↗
(request: httpcore.Request, http2: bool = False)

Source from the content-addressed store, hash-verified

114
115
116def format_request_headers(request: httpcore.Request, http2: bool = False) -> str:
117 version = "HTTP/2" if http2 else "HTTP/1.1"
118 headers = [
119 (name.lower() if http2 else name, value) for name, value in request.headers
120 ]
121 method = request.method.decode("ascii")
122 target = request.url.target.decode("ascii")
123 lines = [f"{method} {target} {version}"] + [
124 f"{name.decode('ascii')}: {value.decode('ascii')}" for name, value in headers
125 ]
126 return "\n".join(lines)
127
128
129def format_response_headers(

Callers 1

print_request_headersFunction · 0.85

Calls 2

joinMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected