client: fix relative paths
This commit is contained in:
@@ -256,7 +256,7 @@ class HTMLDownloadHandler(DownloadHandler):
|
|||||||
if img_src[0] == "/":
|
if img_src[0] == "/":
|
||||||
img_src = f"http://{self.cmd.host}{img_src}"
|
img_src = f"http://{self.cmd.host}{img_src}"
|
||||||
else:
|
else:
|
||||||
img_src = os.path.join(base_url, img_src)
|
img_src = parser.absolute_url(base_url, img_src)
|
||||||
|
|
||||||
if parsed.hostname is None or parsed.hostname == self.cmd.host:
|
if parsed.hostname is None or parsed.hostname == self.cmd.host:
|
||||||
port = self.cmd.port
|
port = self.cmd.port
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import os.path
|
||||||
import re
|
import re
|
||||||
from urllib.parse import urlparse, urlsplit
|
from urllib.parse import urlparse, urlsplit
|
||||||
|
|
||||||
@@ -182,7 +183,6 @@ def parse_headers(lines):
|
|||||||
headers = []
|
headers = []
|
||||||
# first header after the status-line may not contain a space
|
# first header after the status-line may not contain a space
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line = next(lines)
|
|
||||||
if line[0].isspace():
|
if line[0].isspace():
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@@ -251,3 +251,9 @@ def base_url(uri: str):
|
|||||||
parsed = urlsplit(uri)
|
parsed = urlsplit(uri)
|
||||||
path = parsed.path.rsplit("/", 1)[0]
|
path = parsed.path.rsplit("/", 1)[0]
|
||||||
return f"{parsed.scheme}://{parsed.hostname}{path}/"
|
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}"
|
||||||
|
@@ -57,7 +57,7 @@ class PreambleRetriever(Retriever):
|
|||||||
while True:
|
while True:
|
||||||
self.buffer.append(line)
|
self.buffer.append(line)
|
||||||
|
|
||||||
if line in ("\r\n", "\n", " "):
|
if line in ("\r\n", "\n", ""):
|
||||||
break
|
break
|
||||||
|
|
||||||
yield line
|
yield line
|
||||||
|
Reference in New Issue
Block a user