Skip to content

Commit

Permalink
fix: redirection based on location header for methods other than HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
snosratiershad committed Jan 1, 2025
1 parent 10aea09 commit 06c9277
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ s3cmd.egg-info
s3cmd.spec
.idea
.s3cfg
.python-version
2 changes: 1 addition & 1 deletion S3/S3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 06c9277

Please sign in to comment.