(request: httpcore.Request, http2: bool = False)
| 114 | |
| 115 | |
| 116 | def 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 | |
| 129 | def format_response_headers( |
no test coverage detected