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

Optionally allow HTTP redirects #2830

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

simontraill
Copy link

This adds (optional, client configured) support for the HTTP "location" header when processing HTTP redirects for S3 responses.

I'm a developer at NVIDIA; I wrote this on behalf of the AIStore project. We'd really like to use botocore (and boto3) for client access; AIStore (and some other systems - like Apache Ozone, referenced by this issue) rely on standard HTTP redirects - using the "location" header - for load balancing.

botocore constructs redirection URLs using the region instead, and won't allow redirections outside of known Amazon URIs.

I've gated the change here behind a config setting; that said, other AWS SDKs (aws-sdk-go, for instance) do appear to support redirects as normal, so hopefully this behaviour is in line with other clients.

This change -

import boto3
from botocore.config import Config as Config

config = Config(allow_http_redirects=True)
session = boto3.Session()
s3 = session.resource("s3", endpoint_url="http://127.0.0.1:8080/s3", config=config)

I've added unit and functional tests and tried to keep the style consistent with your existing work. If there's any demand for caching using the Cache-Control or Expires headers, I could certainly do it in the follow-up.

Thanks.

@simontraill simontraill changed the title optionally allow http redirects Optionally allow http redirects Dec 9, 2022
@simontraill simontraill changed the title Optionally allow http redirects Optionally allow HTTP redirects Dec 9, 2022
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

Successfully merging this pull request may close these issues.

Support S3 HTTP redirects to non-Amazon URI's by using the location header
1 participant