Return the first matching header value from an ASGI scope.
(
scope: dict[str, Any], header_name: bytes
)
| 156 | |
| 157 | |
| 158 | def _get_scope_header( |
| 159 | scope: dict[str, Any], header_name: bytes |
| 160 | ) -> Optional[str]: |
| 161 | """Return the first matching header value from an ASGI scope.""" |
| 162 | for candidate_name, candidate_value in scope.get("headers", []): |
| 163 | if candidate_name == header_name: |
| 164 | return candidate_value.decode("latin-1").split(",", 1)[0].strip() |
| 165 | return None |
| 166 | |
| 167 | |
| 168 | def _get_request_origin(scope: dict[str, Any]) -> Optional[str]: |
no test coverage detected