api/PostPolicy: Allow location header fully qualified URL (#4926)

req.Host is used to construct the final object location.

Fixes #4910
This commit is contained in:
Harshavardhana
2017-09-24 16:43:21 -07:00
committed by Dee Koder
parent c3ff402fcb
commit 4cadb33da2
5 changed files with 99 additions and 17 deletions

View File

@@ -275,9 +275,25 @@ func getLocation(r *http.Request) string {
return path.Clean(r.URL.Path) // Clean any trailing slashes.
}
// getObjectLocation gets the relative URL for an object
func getObjectLocation(bucketName string, key string) string {
return "/" + bucketName + "/" + key
// returns "https" if the tls boolean is true, "http" otherwise.
func getURLScheme(tls bool) string {
if tls {
return httpsScheme
}
return httpScheme
}
// getObjectLocation gets the fully qualified URL of an object.
func getObjectLocation(host, proto, bucket, object string) string {
if proto == "" {
proto = getURLScheme(globalIsSSL)
}
u := url.URL{
Host: host,
Path: path.Join(slashSeparator, bucket, object),
Scheme: proto,
}
return u.String()
}
// generates ListBucketsResponse from array of BucketInfo which can be