Skip to content

Commit fdef495

Browse files
committed
Use unredirected headers
1 parent f6c4c21 commit fdef495

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tools/build/package

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,17 @@ def _read_manifest(path, platform, versions):
4646

4747

4848
def _download_artifact(uri) -> io.BytesIO:
49-
headers = {}
50-
5149
# Add auth headers if the github token is available, on the build servers it is, but when running locally it is not.
5250
# Some operations do not require authentication but we do it anyway to avoid API call rate problems
51+
request = urllib.request.Request(url=uri)
52+
request.add_unredirected_header(key="Accept", val="application/vnd.github+json")
5353
if 'GITHUB_TOKEN' in os.environ:
5454
GITHUB_TOKEN = os.environ['GITHUB_TOKEN']
55-
headers = {'Authorization': f'token {GITHUB_TOKEN}'}
55+
request.add_unredirected_header(key="Authorization", val=f"Bearer {GITHUB_TOKEN}")
5656
print(' Downloading with authorization')
5757
else:
5858
print(' Downloading without authorization')
59-
60-
req = urllib.request.Request(uri, headers=headers)
61-
with urllib.request.urlopen(req) as response:
59+
with urllib.request.urlopen(request) as response:
6260
data = response.read()
6361
assert (data)
6462
return io.BytesIO(data)

0 commit comments

Comments
 (0)