diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 2c8a6e88b..27d1a8a28 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -755,19 +755,12 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req } // Parse incoming location constraint. - location, s3Error := parseLocationConstraint(r) + _, s3Error = parseLocationConstraint(r) if s3Error != ErrNone { writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL) return } - // Validate if location sent by the client is valid, reject - // requests which do not follow valid region requirements. - if !isValidLocation(location) { - writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrInvalidRegion), r.URL) - return - } - // check if client is attempting to create more buckets, complain about it. if currBuckets := globalBucketMetadataSys.Count(); currBuckets+1 > maxBuckets { logger.LogIf(ctx, fmt.Errorf("An attempt to create %d buckets beyond recommended %d", currBuckets+1, maxBuckets)) diff --git a/cmd/handler-utils.go b/cmd/handler-utils.go index 076407be2..01e83d27a 100644 --- a/cmd/handler-utils.go +++ b/cmd/handler-utils.go @@ -58,6 +58,10 @@ func parseLocationConstraint(r *http.Request) (location string, s3Error APIError if location == "" { location = globalSite.Region } + if !isValidLocation(location) { + return location, ErrInvalidRegion + } + return location, ErrNone }