Skip to content

Commit

Permalink
utils: insert HTTPSHandler also if ftp_tls is True
Browse files Browse the repository at this point in the history
  • Loading branch information
noc0lour committed Jun 15, 2020
1 parent a2d03bf commit e0e2053
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions astropy/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,11 +1004,9 @@ def _download_file_from_source(source_url, show_progress=True, timeout=None,

https_handler = urllib.request.HTTPSHandler(context=ssl_context)
if ftp_tls:
urlopener = urllib.request.build_opener(_FTPTLSHandler())
urlopener = urllib.request.build_opener(_FTPTLSHandler(), https_handler)
else:
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context.load_verify_locations(certifi.where())
urlopener = urllib.request.build_opener(urllib.request.HTTPSHandler(context=ssl_context))
urlopener = urllib.request.build_opener(https_handler)

req = urllib.request.Request(source_url, headers=http_headers)
with urlopener.open(req, timeout=timeout) as remote:
Expand Down

0 comments on commit e0e2053

Please sign in to comment.