I don't believe Python's urllib has a function that takes what HTTP terms an "origin-form" (an absolute path with possibly a query attached to it with "?") and parses it apart.

Still, the RFC 9112 that defines HTTP/1.1 basics requires that, for the purposes of URI reconstruction, "if there is no Host header field or if its field value is empty or invalid, the target URI's authority component is empty."

https://docs.python.org/3/library/urllib.parse.html

Yep, none of them are suitable for this use case; you need to validate the Host header first and reconstruct the URI first before parsing it.

[deleted]

[dead]