MCPcopy
hub / github.com/encode/starlette / test_url_from_scope_with_invalid_host

Function test_url_from_scope_with_invalid_host

tests/test_datastructures.py:184–196  ·  view source on GitHub ↗

An invalid Host header should be ignored, falling back to the server tuple.

(host: bytes)

Source from the content-addressed store, hash-verified

182 ],
183)
184def 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(

Callers

nothing calls this directly

Calls 1

URLClass · 0.90

Tested by

no test coverage detected