From 640a90f3f9df94297516af9c5e025e8ffde04de8 Mon Sep 17 00:00:00 2001 From: Colin Cornaby Date: Sun, 14 Jul 2024 22:14:34 -0700 Subject: [PATCH] Not passing headers when redirected GitHub is using Azure blob storage which does not expect an authorization header. Need to make sure this header is not being passed on the redirect or the download will fail. --- urumanifest/github.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/urumanifest/github.py b/urumanifest/github.py index 839385b..2d5d6a3 100644 --- a/urumanifest/github.py +++ b/urumanifest/github.py @@ -176,10 +176,8 @@ def query_result() -> str: def download_file(self, url: str, hook: Callable[[int, int, int], None] = None, delete: bool = True) -> tempfile.NamedTemporaryFile: logging.trace(f"Downloading {url}") - headers = dict() - if self._token is not None: - headers["Authorization"] = f"token {self._token}" - req = urllib.request.Request(url, headers=headers) + req = urllib.request.Request(url) + req.add_unredirected_header("Authorization", f"token {self._token}") with closing(urllib.request.urlopen(req)) as res: fp = tempfile.NamedTemporaryFile("w+b", delete=delete) size, block = 0, 1024 * 8