api: MakeBucket should set proper bucket location. (#1948)

Fixes #1942
master
Harshavardhana 8 years ago committed by GitHub
parent ad779a8ba4
commit 409b4ddecb
  1. 3
      api-response.go
  2. 13
      server_xl_test.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

@ -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)

Loading…
Cancel
Save