client: fix image url parsing

This commit is contained in:
2021-03-25 17:56:21 +01:00
parent b37aa33131
commit f15ff38f69
7 changed files with 24 additions and 60 deletions

View File

@@ -6,11 +6,13 @@ class Message:
status: int
msg: str
headers: Dict[str, str]
raw: str
body: bytes
def __init__(self, version: str, status: int, msg: str, headers: Dict[str, str], body: bytes = None):
def __init__(self, version: str, status: int, msg: str, headers: Dict[str, str], raw=None, body: bytes = None):
self.version = version
self.status = status
self.msg = msg
self.headers = headers
self.raw = raw
self.body = body

View File

@@ -245,3 +245,9 @@ def parse_uri(uri: str):
port = 80
return host, port, path
def base_url(uri: str):
parsed = urlsplit(uri)
path = parsed.path.rsplit("/", 1)[0]
return f"{parsed.scheme}://{parsed.hostname}{path}/"