From 409b4ddecb3e799158fe1a03e8b30e63a94180d9 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 20 Jun 2016 23:25:18 -0700 Subject: [PATCH] api: MakeBucket should set proper bucket location. (#1948) Fixes #1942 --- api-response.go | 3 ++- server_xl_test.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/api-response.go b/api-response.go index 8216e8025..df4f0904f 100644 --- a/api-response.go +++ b/api-response.go @@ -19,6 +19,7 @@ package main import ( "encoding/xml" "net/http" + "path" "time" ) @@ -255,7 +256,7 @@ type DeleteObjectsResponse struct { // getLocation get URL location. func getLocation(r *http.Request) string { - return r.URL.Path + return path.Clean(r.URL.Path) // Clean any trailing slashes. } // getObjectLocation gets the relative URL for an object diff --git a/server_xl_test.go b/server_xl_test.go index 62149d56a..a2c201da0 100644 --- a/server_xl_test.go +++ b/server_xl_test.go @@ -1513,6 +1513,19 @@ func (s *MyAPIXLSuite) TestBucketMultipartList(c *C) { c.Assert(newResponse3.Bucket, Equals, "bucketmultipartlist") } +// TestMakeBucketLocation - tests make bucket location header response. +func (s *MyAPIXLSuite) TestMakeBucketLocation(c *C) { + request, err := s.newRequest("PUT", testAPIXLServer.URL+"/make-bucket-location", 0, nil) + c.Assert(err, IsNil) + + client := http.Client{} + response, err := client.Do(request) + c.Assert(err, IsNil) + c.Assert(response.StatusCode, Equals, 200) + // Validate location header value equals proper bucket name. + c.Assert(response.Header.Get("Location"), Equals, "/make-bucket-location") +} + func (s *MyAPIXLSuite) TestValidateObjectMultipartUploadID(c *C) { request, err := s.newRequest("PUT", testAPIXLServer.URL+"/objectmultipartlist-uploadid", 0, nil) c.Assert(err, IsNil)