Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 5 additions & 8 deletions src/gpu_index/common/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
from contextlib import contextmanager
from typing import Iterator, Optional

# One identity across every repository that collects for this index. The
# +URL is getcomputable.com and NOT this repository: a repo URL stops
# resolving if the repo is renamed or made private, and a 404 is no better
# than no contact at all.
UA = (
"CGI-Collector/1.0 (+https://getcomputable.com; "
"team@getcomputable.com)"
)
# The User-Agent sent with every request: a neutral product token, not a
# library default and not a browser string. An operator running this code
# under their own identity can install a different value for a scope with
# user_agent_scope().
UA = "gpu-index/1.0"
_USER_AGENT_OVERRIDE: contextvars.ContextVar[Optional[str]] = contextvars.ContextVar(
"gpu_index_user_agent_override", default=None
)
Expand Down
7 changes: 2 additions & 5 deletions tests/unit/test_public_read_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_from_env_without_public_url_keeps_local_default(tmp_path):
# ------------------------------------------------------- get-object reads


def test_get_bytes_returns_body_with_cgi_user_agent():
def test_get_bytes_returns_body_with_collector_user_agent():
seen = {}

def handler(request: httpx.Request) -> httpx.Response:
Expand All @@ -87,10 +87,7 @@ def handler(request: httpx.Request) -> httpx.Response:
f"{BASE_URL}/index/basket/composites/m1/2026-08-16.json"
)
assert seen["ua"] == UA
assert "CGI-Collector/" in seen["ua"]
# No browser prefix: the UA is a public identity, and the bot
# protection on the collected hosts screens an unidentified client,
# not the absence of a browser string.
# The token claims no browser.
assert not seen["ua"].lower().startswith("mozilla/")


Expand Down
Loading