Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions simple_httpfs/httpfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def __init__(self, logger):
)

def get_size(self, url):
# TODO avoid try/except, use "if key in dict"
try:
head = requests.head(url, allow_redirects=True, verify=self.SSL_VERIFY)
return int(head.headers["Content-Length"])
Expand All @@ -146,6 +147,9 @@ def get_size(self, url):
verify=self.SSL_VERIFY,
headers={"Range": "bytes=0-1"},
)
if "Content-Length" in head.headers:
# google server sends Content-Length on head request 2
return int(head.headers["Content-Length"])
crange = head.headers["Content-Range"]
match = re.search(r"/(\d+)$", crange)
if match:
Expand Down