From d3e7d7855ac61c9b46891d2c6e49b988e21baeb3 Mon Sep 17 00:00:00 2001 From: mikedarcy Date: Tue, 13 Feb 2024 16:10:42 -0800 Subject: [PATCH] Fix issue with HTTP fetch handler and auth header bearer-token stripping 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. --- bdbag/bdbag_api.py | 5 +++-- bdbag/fetch/transports/fetch_http.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bdbag/bdbag_api.py b/bdbag/bdbag_api.py index afc0962..285c1aa 100644 --- a/bdbag/bdbag_api.py +++ b/bdbag/bdbag_api.py @@ -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 diff --git a/bdbag/fetch/transports/fetch_http.py b/bdbag/fetch/transports/fetch_http.py index efde64f..e85b4d4 100644 --- a/bdbag/fetch/transports/fetch_http.py +++ b/bdbag/fetch/transports/fetch_http.py @@ -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: