Skip to content

Commit 1068c67

Browse files
Validate URL scheme and host in request
Add validation for URL scheme and netloc in request
1 parent bd59af5 commit 1068c67

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/ahttpx/_request.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ def __init__(
2929
if "Host" not in self.headers:
3030
self.headers = self.headers.copy_set("Host", self.url.netloc)
3131

32+
if self.url.scheme not in ('http', 'https'):
33+
raise ValueError(f'Invalid scheme for URL {str(self.url)!r}.')
34+
if not self.url.netloc:
35+
raise ValueError(f'Missing host for URL {str(self.url)!r}.')
36+
3237
if content is not None:
3338
if isinstance(content, bytes):
3439
self.stream = ByteStream(content)

0 commit comments

Comments
 (0)