Return a clean header dict, dropping hop-by-hop and proxy headers.
(raw: object)
| 116 | |
| 117 | |
| 118 | def _sanitize_headers(raw: object) -> dict[str, str]: |
| 119 | """Return a clean header dict, dropping hop-by-hop and proxy headers.""" |
| 120 | if not isinstance(raw, dict): |
| 121 | return {} |
| 122 | out: dict[str, str] = {} |
| 123 | for k, v in raw.items(): |
| 124 | if not k or not isinstance(k, str): |
| 125 | continue |
| 126 | if k.lower() in _STRIP_HEADERS: |
| 127 | continue |
| 128 | out[k] = str(v) if v is not None else "" |
| 129 | return out |
| 130 | |
| 131 | |
| 132 | def _safe_url(url: str) -> bool: |