Skip to content

Commit 91ea364

Browse files
authored
Merge pull request #523 from bioimage-io/ci_user_agent
requests: set User-Agent to "ci" in a CI environment
2 parents 451cf4e + 0ec5f28 commit 91ea364

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

bioimageio/spec/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "0.4.9"
2+
"version": "0.4.9post1"
33
}

bioimageio/spec/shared/_resolve_source.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,15 @@ def _download_url(uri: raw_nodes.URI, output: typing.Optional[os.PathLike] = Non
466466
# download with tqdm adapted from:
467467
# https://github.com/shaypal5/tqdl/blob/189f7fd07f265d29af796bee28e0893e1396d237/tqdl/core.py
468468
# Streaming, so we can iterate over the response.
469-
r = requests.get(str(uri), stream=True)
469+
headers = {}
470+
if os.environ.get("CI", "false").lower() in ("1", "t", "true", "yes", "y"):
471+
headers["User-Agent"] = "ci"
472+
473+
user_agent = os.environ.get("BIOIMAGEIO_USER_AGENT")
474+
if user_agent is not None:
475+
headers["User-Agent"] = user_agent
476+
477+
r = requests.get(str(uri), stream=True, headers=headers)
470478
r.raise_for_status()
471479
# Total size in bytes.
472480
total_size = int(r.headers.get("content-length", 0))

0 commit comments

Comments
 (0)