mirror of
https://github.com/openai/codex.git
synced 2026-10-21 04:48:12 +00:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user