Skip to content

Commit 1b303af

Browse files
committed
修复 pages-site artifact 下载:redirect 到 CDN 时去掉 Authorization,避免 401。
1 parent 7c144ad commit 1b303af

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

scripts/ci/download-latest-pages-site.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,23 @@ req = urllib.request.Request(
9393
"User-Agent": "nebula-bench-pages-merge",
9494
},
9595
)
96-
with urllib.request.urlopen(req, timeout=180) as resp:
96+
97+
98+
class _StripAuthOnRedirect(urllib.request.HTTPRedirectHandler):
99+
"""Artifact CDN redirects reject GitHub Authorization; strip it on hop."""
100+
101+
def redirect_request(self, req, fp, code, msg, headers, newurl):
102+
new_req = super().redirect_request(req, fp, code, msg, headers, newurl)
103+
if new_req is None:
104+
return None
105+
for key in list(new_req.headers.keys()):
106+
if key.lower() in ("authorization", "accept"):
107+
del new_req.headers[key]
108+
return new_req
109+
110+
111+
opener = urllib.request.build_opener(_StripAuthOnRedirect)
112+
with opener.open(req, timeout=180) as resp:
97113
blob = resp.read()
98114
99115
with zipfile.ZipFile(BytesIO(blob)) as zf:

0 commit comments

Comments
 (0)