client: fix relative paths
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import os.path
|
||||
import re
|
||||
from urllib.parse import urlparse, urlsplit
|
||||
|
||||
@@ -182,7 +183,6 @@ def parse_headers(lines):
|
||||
headers = []
|
||||
# first header after the status-line may not contain a space
|
||||
for line in lines:
|
||||
line = next(lines)
|
||||
if line[0].isspace():
|
||||
continue
|
||||
else:
|
||||
@@ -251,3 +251,9 @@ def base_url(uri: str):
|
||||
parsed = urlsplit(uri)
|
||||
path = parsed.path.rsplit("/", 1)[0]
|
||||
return f"{parsed.scheme}://{parsed.hostname}{path}/"
|
||||
|
||||
|
||||
def absolute_url(uri: str, rel_path: str):
|
||||
parsed = urlsplit(uri)
|
||||
path = os.path.normpath(os.path.join(parsed.path, rel_path))
|
||||
return f"{parsed.scheme}://{parsed.hostname}{path}"
|
||||
|
Reference in New Issue
Block a user