Skip to content

Commit 8c162c0

Browse files
committed
follow_redirects=True
1 parent 05923af commit 8c162c0

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

bioimageio/spec/_internal/io_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def open_bioimageio_yaml(
167167
)
168168

169169
try:
170-
r = httpx.get(url)
170+
r = httpx.get(url, follow_redirects=True)
171171
_ = r.raise_for_status()
172172
unparsed_content = r.content.decode(encoding="utf-8")
173173
content = _sanitize_bioimageio_yaml(read_yaml(unparsed_content))
@@ -232,7 +232,7 @@ def _get_id_map_impl(url: str) -> Dict[str, LightHttpFileDescr]:
232232
if not isinstance(url, str) or "/" not in url:
233233
logger.opt(depth=1).error("invalid id map url: {}", url)
234234
try:
235-
id_map_raw: Any = httpx.get(url, timeout=10).json()
235+
id_map_raw: Any = httpx.get(url, timeout=10, follow_redirects=True).json()
236236
except Exception as e:
237237
logger.opt(depth=1).error("failed to get {}: {}", url, e)
238238
return {}

bioimageio/spec/_internal/url.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,17 @@ def _validate_url_impl(
5858
try:
5959
if request_mode in ("head", "get"):
6060
request_ctxt = nullcontext(
61-
httpx.request(request_mode.upper(), val_url, timeout=timeout)
61+
httpx.request(
62+
request_mode.upper(),
63+
val_url,
64+
timeout=timeout,
65+
follow_redirects=True,
66+
)
6267
)
6368
elif request_mode == "get_stream":
64-
request_ctxt = httpx.stream("GET", val_url, timeout=timeout)
69+
request_ctxt = httpx.stream(
70+
"GET", val_url, timeout=timeout, follow_redirects=True
71+
)
6572
else:
6673
assert_never(request_mode)
6774

bioimageio/spec/_upload.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def upload(
124124
"file_path": file_name,
125125
},
126126
headers=headers,
127+
follow_redirects=True,
127128
)
128129
upload_url = response.raise_for_status().json()
129130

@@ -140,6 +141,7 @@ def upload(
140141
files=files, # pyright: ignore[reportArgumentType]
141142
# TODO: follow up on https://github.com/encode/httpx/discussions/3611
142143
headers={"Content-Type": ""}, # Important for S3 uploads
144+
follow_redirects=True,
143145
)
144146
logger.info("Uploaded '{}' successfully", file_name)
145147

@@ -153,6 +155,7 @@ def upload(
153155
"manifest": manifest,
154156
},
155157
headers=headers,
158+
follow_redirects=True,
156159
)
157160
logger.info(
158161
"Updated status of {}/{} to 'request-review'", artifact_id, artifact_version

scripts/update_spdx_licenses_zenodo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def main(recheck: bool = False):
3232
"https://zenodo.org/api/vocabularies/licenses/"
3333
+ lic["licenseId"].lower()
3434
)
35-
r = httpx.get(url, timeout=5)
35+
r = httpx.get(url, timeout=5, follow_redirects=True)
3636

3737
if 200 <= r.status_code < 300:
3838
known = True

0 commit comments

Comments
 (0)