Skip to content

Commit

Permalink
Allow the FileDownload class to follow redirects.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Jun 18, 2024
1 parent c2a1b3d commit 15ef080
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion kolibri/utils/file_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,15 @@ def _set_headers(self):
if self._headers_set:
return

response = self.session.head(self.source, timeout=self.timeout)
response = self.session.head(
self.source, timeout=self.timeout, allow_redirects=True
)
response.raise_for_status()

if response.url != self.source:
logger.debug("Redirected from {} to {}".format(self.source, response.url))
self.source = response.url

self.compressed = bool(response.headers.get("content-encoding", ""))

self.content_length_header = "content-length" in response.headers
Expand Down

0 comments on commit 15ef080

Please sign in to comment.