From e700be8cd6cd775e7b90d4afea0447b41410072a Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 15 Mar 2023 13:40:40 -0700 Subject: [PATCH] fix: return appropriate Location header for MakeBucket() (#16820) --- cmd/bucket-handlers.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 27d1a8a28..40f417aa1 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -796,8 +796,7 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req globalNotificationSys.LoadBucketMetadata(GlobalContext, bucket) // Make sure to add Location information here only for bucket - w.Header().Set(xhttp.Location, - getObjectLocation(r, globalDomainNames, bucket, "")) + w.Header().Set(xhttp.Location, pathJoin(SlashSeparator, bucket)) writeSuccessResponseHeadersOnly(w) @@ -848,9 +847,7 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req logger.LogIf(ctx, globalSiteReplicationSys.MakeBucketHook(ctx, bucket, opts)) // Make sure to add Location information here only for bucket - if cp := pathClean(r.URL.Path); cp != "" { - w.Header().Set(xhttp.Location, cp) // Clean any trailing slashes. - } + w.Header().Set(xhttp.Location, pathJoin(SlashSeparator, bucket)) writeSuccessResponseHeadersOnly(w) @@ -1123,7 +1120,9 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h w.Header()[xhttp.AmzVersionID] = []string{objInfo.VersionID} } - w.Header().Set(xhttp.Location, getObjectLocation(r, globalDomainNames, bucket, object)) + if obj := getObjectLocation(r, globalDomainNames, bucket, object); obj != "" { + w.Header().Set(xhttp.Location, obj) + } // Notify object created event. defer sendEvent(eventArgs{