Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect fails when the URL in location header contains a port number #1327

Open
yima77 opened this issue May 11, 2023 · 0 comments
Open

Redirect fails when the URL in location header contains a port number #1327

yima77 opened this issue May 11, 2023 · 0 comments

Comments

@yima77
Copy link

yima77 commented May 11, 2023

When s3cmd gets a 301 response with a location header that contains a port number, such as:

location: http://1.5.11.69:8002/test-bucket/file-1

It will be redirected to 1.5.11.69, instead of 1.5.11.69:8002. I checked the code and found that the issue is with this line in S3.py:

            location_url = urlparse('https://' + location_url).hostname

at line 1440.

It should be:

            location_url = urlparse('https://' + location_url).netloc

since hostname doesn't contain the port part.

After this simple change, redirect works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant