From bc1f22455d1f5f3fe3d4dc3ca964ec75966a6c1c Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Thu, 8 Oct 2026 16:59:16 +0000 Subject: [PATCH] Set a User-Agent for package archive downloads (#52177) Send `User-Agent: codex-package` when downloading archives in `scripts/codex_package/dotslash.py`. GitOrigin-RevId: b12dc962b28d795704ba780b020fbf7ab91f5d50 --- scripts/codex_package/dotslash.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/codex_package/dotslash.py b/scripts/codex_package/dotslash.py index ba0adbe244..8b2d6bcde3 100644 --- a/scripts/codex_package/dotslash.py +++ b/scripts/codex_package/dotslash.py @@ -11,7 +11,7 @@ import zipfile from dataclasses import dataclass from pathlib import Path from urllib.parse import urlparse -from urllib.request import urlopen +from urllib.request import Request, urlopen from .targets import TargetSpec @@ -168,7 +168,8 @@ def download_archive(url: str, archive_path: Path) -> None: temp_path = archive_path.with_suffix(f"{archive_path.suffix}.tmp") temp_path.unlink(missing_ok=True) try: - with urlopen(url, timeout=DOWNLOAD_TIMEOUT_SECS) as response: + request = Request(url, headers={"User-Agent": "codex-package"}) + with urlopen(request, timeout=DOWNLOAD_TIMEOUT_SECS) as response: with open(temp_path, "wb") as out: shutil.copyfileobj(response, out) temp_path.replace(archive_path)