Make sure url, filename and headers are strings before downloading.
This commit is contained in:
parent
9b0d4f6118
commit
92a37b7d81
|
@ -106,6 +106,11 @@ def download_file(url, filename, callback=None, headers=None):
|
||||||
:raises t.w.e.Error: for all other HTTP response errors (besides OK)
|
:raises t.w.e.Error: for all other HTTP response errors (besides OK)
|
||||||
"""
|
"""
|
||||||
url = str(url)
|
url = str(url)
|
||||||
|
filename = str(filename)
|
||||||
|
if headers:
|
||||||
|
for key, value in headers.items():
|
||||||
|
headers[str(key)] = str(value)
|
||||||
|
|
||||||
scheme, host, port, path = client._parse(url)
|
scheme, host, port, path = client._parse(url)
|
||||||
factory = HTTPDownloader(url, filename, callback, headers)
|
factory = HTTPDownloader(url, filename, callback, headers)
|
||||||
if scheme == "https":
|
if scheme == "https":
|
||||||
|
|
|
@ -229,7 +229,7 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
headers = {}
|
headers = {}
|
||||||
if self.config["last_update"] and not self.force_download:
|
if self.config["last_update"] and not self.force_download:
|
||||||
headers['If-Modified-Since'] = str(self.config["last_update"])
|
headers['If-Modified-Since'] = self.config["last_update"]
|
||||||
|
|
||||||
log.debug("Attempting to download blocklist %s" % url)
|
log.debug("Attempting to download blocklist %s" % url)
|
||||||
log.debug("Sending headers: %s" % headers)
|
log.debug("Sending headers: %s" % headers)
|
||||||
|
|
|
@ -459,7 +459,7 @@ class WebApi(JSONComponent):
|
||||||
log.debug("filename: %s", tmp_file)
|
log.debug("filename: %s", tmp_file)
|
||||||
headers = {}
|
headers = {}
|
||||||
if cookie:
|
if cookie:
|
||||||
headers["Cookie"] = str(cookie)
|
headers["Cookie"] = cookie
|
||||||
log.debug("cookie: %s", cookie)
|
log.debug("cookie: %s", cookie)
|
||||||
return httpdownloader.download_file(url, tmp_file, headers=headers)
|
return httpdownloader.download_file(url, tmp_file, headers=headers)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue