Skip to content

Commit bf7f4f4

Browse files
committed
Manage proxies & auth just in case
1 parent 744f196 commit bf7f4f4

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

biomaj_download/download/curl.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,26 @@ def _estimate_size(self, rfile):
328328

329329
def _head_size_call(self, full_url):
330330
# Now do a HEAD call on this url
331+
332+
auth = ()
333+
proxies = {}
334+
335+
if self.credentials is not None:
336+
auth = tuple(self.credentials.split(":"))
337+
338+
if self.proxy is not None:
339+
proxy = self.proxy
340+
if not self.proxy.startswith("http"):
341+
proxy = 'http://' + self.proxy
342+
if self.proxy_auth is not None:
343+
# Don't really want to manage properly the various schemes
344+
proxy.replace('http://', 'http://{}@'.format(self.proxy_auth))
345+
proxy.replace('https://', 'https://{}@'.format(self.proxy_auth))
346+
proxies['http'] = proxy
347+
proxies['https'] = proxy
348+
331349
try:
332-
size_response = requests.head(full_url, allow_redirects=True)
350+
size_response = requests.head(full_url, allow_redirects=True, auth=auth, proxies=proxies)
333351
size = int(size_response.headers.get('content-length', 0))
334352
return size
335353

0 commit comments

Comments
 (0)