Skip to content

Commit d805a5b

Browse files
committed
PB-1024: remove unnecessary HTTP 206 exception handler from probe_asset
HTTP 206 (Partial Content) is a success status code, not an error, so urllib.request.urlopen() returns it normally without raising an HTTPError.
1 parent 84c6882 commit d805a5b

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

download-data/stac-api/large-assets.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,9 @@ def probe_asset(url):
112112
"""
113113
print('Probing asset via range request...')
114114
req = urllib.request.Request(url, headers={'Range': 'bytes=0-0'})
115-
try:
116-
with urllib.request.urlopen(req, timeout=30) as resp:
117-
content_range = resp.headers.get('Content-Range', '')
118-
sha256 = resp.headers.get('x-amz-meta-sha256', '')
119-
except urllib.error.HTTPError as exc:
120-
if exc.code == 206:
121-
content_range = exc.headers.get('Content-Range', '')
122-
sha256 = exc.headers.get('x-amz-meta-sha256', '')
123-
else:
124-
raise
115+
with urllib.request.urlopen(req, timeout=30) as resp:
116+
content_range = resp.headers.get('Content-Range', '')
117+
sha256 = resp.headers.get('x-amz-meta-sha256', '')
125118

126119
total_size = None
127120
if '/' in content_range:

0 commit comments

Comments
 (0)