Index: smart/fetcher.py =================================================================== --- smart/fetcher.py (revision 896) +++ smart/fetcher.py (working copy) @@ -487,11 +487,15 @@ # - size: file size # - uncomp: whether to uncompress or not # - uncomp_{md5,sha,size}: uncompressed equivalents + # - http_headers: extra http headers needed for the download request # - for kind in ("md5", "sha", "uncomp_md5", "uncomp_sha"): + for kind in ("md5", "sha", "uncomp_md5", "uncomp_sha", "http_headers"): value = info.get(kind) if value: - info[kind] = value.lower() + try: + info[kind] = value.lower() + except AttributeError: + pass self._info.update(info) def start(self): @@ -1171,6 +1175,12 @@ else: partsize = 0 + extraheaders = item.getInfo("http_headers") + if extraheaders: + for key in extraheaders.keys(): + value = extraheaders[key] + opener.addheader(key, "%s" % value) + remote = opener.open(url.original) if hasattr(remote, "errcode") and remote.errcode == 416: @@ -1619,6 +1629,25 @@ handle.localpath = localpath handle.active = len(hostactive) + if sysconf.get("ignore-invalid-certificates", False): + # Disable certificate verifying for self-signed servers. + handle.setopt(pycurl.SSL_VERIFYPEER, 0) + handle.setopt(pycurl.SSL_VERIFYHOST, 0) + + extraheaders = item.getInfo("http_headers") + if extraheaders: + requestheaders = [] + for key in extraheaders: + value = extraheaders[key] + if not value: + # Trick to send and empty header + lastheader = requestheaders.pop() + lastheader = lastheader + "\r\n" + key + ":" + requestheaders.append(lastheader) + else: + requestheaders.append("%s: %s" % (key, extraheaders[key])) + handle.setopt(pycurl.HTTPHEADER, requestheaders) + item.start() def progress(downtotal, downcurrent,