From 1068c67f5a102f7ba119e5e41418f1451506980d Mon Sep 17 00:00:00 2001 From: Kim Christie Date: Wed, 17 Dec 2025 13:57:27 +0000 Subject: [PATCH] Validate URL scheme and host in request Add validation for URL scheme and netloc in request --- src/ahttpx/_request.py | 5 +++++ 1 file changed, 5 insertions(+) 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)