Skip to content

Commit

Permalink
Fix issue with HTTP fetch handler and auth header bearer-token stripp…
Browse files Browse the repository at this point in the history
…ing on redirects not getting restored to the session after redirect. Thought this was fixed already but apparently not.

Added a couple of extra logging statements.
  • Loading branch information
mikedarcy committed Feb 14, 2024
1 parent f8d8136 commit d3e7d78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions bdbag/bdbag_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ def is_bag(bag_path):
bag = None
try:
bag = bdbagit.BDBag(bag_path)
except (bdbagit.BagError, bdbagit.BagValidationError): # pragma: no cover
pass
except (bdbagit.BagError, bdbagit.BagValidationError) as e: # pragma: no cover
logger.warning("Exception while checking if %s is a bag: %s" % (bag_path, e))
return True if bag else False


def check_payload_consistency(bag, skip_remote=False, quiet=False):
logger.info("Checking payload consistency. This can take some time for large bags with many payload files...")

only_in_manifests, only_on_fs, only_in_fetch = bag.compare_manifests_with_fs_and_fetch()
payload_consistent = not only_on_fs
Expand Down
4 changes: 2 additions & 2 deletions bdbag/fetch/transports/fetch_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ def fetch(self, url, output_path, **kwargs):
cookies=self.cookies)
if r.status_code in redirect_status_codes:
url = r.headers["Location"]
logger.info("Server responded with redirect to: %s" % url)
logger.info("Server responded with redirect.")
if auth_type == "bearer-token":
authorization = session.headers.get("Authorization")
if allow_redirects_with_token:
authorization = session.headers.get("Authorization")
if authorization:
headers.update({"Authorization": authorization})
else:
Expand Down

0 comments on commit d3e7d78

Please sign in to comment.