From: Kim Christie Date: Wed, 17 Dec 2025 13:57:27 +0000 (+0000) Subject: Validate URL scheme and host in request X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1068c67f5a102f7ba119e5e41418f1451506980d;p=thirdparty%2Fhttpx.git Validate URL scheme and host in request Add validation for URL scheme and netloc in request --- diff --git a/src/ahttpx/_request.py b/src/ahttpx/_request.py index 78b82282..a247b8b4 100644 --- a/src/ahttpx/_request.py +++ b/src/ahttpx/_request.py @@ -29,6 +29,11 @@ class Request: if "Host" not in self.headers: self.headers = self.headers.copy_set("Host", self.url.netloc) + if self.url.scheme not in ('http', 'https'): + raise ValueError(f'Invalid scheme for URL {str(self.url)!r}.') + if not self.url.netloc: + raise ValueError(f'Missing host for URL {str(self.url)!r}.') + if content is not None: if isinstance(content, bytes): self.stream = ByteStream(content)