Validate URL scheme and host in request
Add validation for URL scheme and netloc in request
This commit is contained in:
parent
bd59af5fd6
commit
1068c67f5a
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user