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
OADP-659 Remove HTTP/HTTPS port numbers from AWS S3 URLs. #1169
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,12 @@ package bucket | |
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"net/url" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/awserr" | ||
"github.com/aws/aws-sdk-go/aws/request" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/s3" | ||
"github.com/aws/aws-sdk-go/service/s3/s3iface" | ||
|
@@ -170,3 +173,18 @@ func (a awsBucketClient) Delete() (bool, error) { | |
|
||
return true, nil | ||
} | ||
|
||
// StripDefaultPorts removes port 80 from HTTP URLs and 443 from HTTPS URLs. | ||
// Defer to the actual AWS SDK implementation to match its behavior exactly. | ||
func StripDefaultPorts(fromUrl string) (string, error) { | ||
u, err := url.Parse(fromUrl) | ||
if err != nil { | ||
return "", err | ||
} | ||
r := http.Request{ | ||
URL: u, | ||
} | ||
request.SanitizeHostForHeader(&r) | ||
r.URL.Host = r.Host | ||
return r.URL.String(), nil | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM but I would move this to more generic place.. maybe util.go you never know when this might be needed for non aws. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I tried moving this to pkg/common. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code will get executed for minio as well as noobaa, right ? Any idea if we need this port stripping for them too ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it needs to run for anything that goes through the AWS SDK. I don't know if minio already deals with this, but I will try it and see. I think this change shouldn't cause any existing working connection types to stop working.