Fix issues
This commit is contained in:
@@ -82,11 +82,15 @@ class HTTPSocket:
|
||||
|
||||
|
||||
class HTTPException(Exception):
|
||||
""" Base class for HTTP exceptions """
|
||||
"""
|
||||
Base class for HTTP exceptions
|
||||
"""
|
||||
|
||||
|
||||
class InvalidResponse(HTTPException):
|
||||
""" Response message cannot be parsed """
|
||||
"""
|
||||
Response message cannot be parsed
|
||||
"""
|
||||
|
||||
def __init(self, message):
|
||||
self.message = message
|
||||
|
@@ -174,13 +174,21 @@ def parse_uri(uri: str):
|
||||
return host, port, path
|
||||
|
||||
|
||||
def get_uri(url: str):
|
||||
def uri_from_url(url: str):
|
||||
"""
|
||||
Returns a valid URI of the specified URL.
|
||||
"""
|
||||
parsed = urlsplit(url)
|
||||
|
||||
result = f"http://{parsed.netloc}{parsed.path}"
|
||||
if parsed.hostname is None:
|
||||
url = f"http://{url}"
|
||||
parsed = urlsplit(url)
|
||||
|
||||
path = parsed.path
|
||||
if path == "":
|
||||
path = "/"
|
||||
|
||||
result = f"http://{parsed.netloc}{path}"
|
||||
if parsed.query != "":
|
||||
result = f"{result}?{parsed.query}"
|
||||
|
||||
|
Reference in New Issue
Block a user