Skip to content

Commit 442383b

Browse files
author
Benjamin Moody
committed
_remote_file_size: use openurl in place of requests.head.
1 parent d95af13 commit 442383b

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

wfdb/io/download.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,8 @@ def _remote_file_size(url=None, file_name=None, pn_dir=None):
9898
if file_name and pn_dir:
9999
url = posixpath.join(config.db_index_url, pn_dir, file_name)
100100

101-
response = requests.head(url, headers={'Accept-Encoding': 'identity'})
102-
# Raise HTTPError if invalid url
103-
response.raise_for_status()
104-
105-
# Supposed size of the file
106-
remote_file_size = int(response.headers['content-length'])
101+
with _url.openurl(url, 'rb') as f:
102+
remote_file_size = f.seek(0, os.SEEK_END)
107103

108104
return remote_file_size
109105

0 commit comments

Comments
 (0)