Make sure url, filename and headers are strings before downloading.

This commit is contained in:
John Garland 2009-08-01 03:00:04 +00:00
parent 9b0d4f6118
commit 92a37b7d81
3 changed files with 7 additions and 2 deletions

View File

@ -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)
"""
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)
factory = HTTPDownloader(url, filename, callback, headers)
if scheme == "https":

View File

@ -229,7 +229,7 @@ class Core(CorePluginBase):
headers = {}
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("Sending headers: %s" % headers)

View File

@ -459,7 +459,7 @@ class WebApi(JSONComponent):
log.debug("filename: %s", tmp_file)
headers = {}
if cookie:
headers["Cookie"] = str(cookie)
headers["Cookie"] = cookie
log.debug("cookie: %s", cookie)
return httpdownloader.download_file(url, tmp_file, headers=headers)