An invalid Host header should be ignored, falling back to the server tuple.
(host: bytes)
| 182 | ], |
| 183 | ) |
| 184 | def test_url_from_scope_with_invalid_host(host: bytes) -> None: |
| 185 | """An invalid Host header should be ignored, falling back to the server tuple.""" |
| 186 | u = URL( |
| 187 | scope={ |
| 188 | "scheme": "http", |
| 189 | "server": ("example.com", 80), |
| 190 | "path": "/admin", |
| 191 | "query_string": b"", |
| 192 | "headers": [(b"host", host)], |
| 193 | } |
| 194 | ) |
| 195 | assert u.path == "/admin" |
| 196 | assert u.netloc == "example.com" |
| 197 | |
| 198 | |
| 199 | @pytest.mark.parametrize( |