From 06c927745685139f3e8776caf02ac3ac5108201c Mon Sep 17 00:00:00 2001 From: Salar Nosrati-Ershad Date: Wed, 1 Jan 2025 20:03:15 +0330 Subject: [PATCH] fix: redirection based on location header for methods other than HEAD --- .gitignore | 1 + S3/S3.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 06a228f49..84ee0a167 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ s3cmd.egg-info s3cmd.spec .idea .s3cfg +.python-version diff --git a/S3/S3.py b/S3/S3.py index d4cac8f99..b93a26a6b 100644 --- a/S3/S3.py +++ b/S3/S3.py @@ -1581,7 +1581,7 @@ def _http_redirection_handler(self, request, response, fn, *args, **kwargs): S3Request.region_map[redir_bucket] = redir_region info(u'Redirected to region: %s', redir_region) return fn(*args, **kwargs) - elif request.method_string == 'HEAD': + elif response['headers'].get('location'): # Head is a special case, redirection info usually are in the body # but there is no body for an HEAD request. location_url = response['headers'].get('location')