|
|
@ -920,18 +920,27 @@ func (s *MyAPIXLSuite) TestPartialContent(c *C) { |
|
|
|
c.Assert(response.StatusCode, Equals, http.StatusOK) |
|
|
|
c.Assert(response.StatusCode, Equals, http.StatusOK) |
|
|
|
|
|
|
|
|
|
|
|
// Prepare request
|
|
|
|
// Prepare request
|
|
|
|
request, err = s.newRequest("GET", testAPIXLServer.URL+"/partial-content/bar", 0, nil) |
|
|
|
var table = []struct { |
|
|
|
c.Assert(err, IsNil) |
|
|
|
byteRange string |
|
|
|
request.Header.Add("Range", "bytes=6-7") |
|
|
|
expectedString string |
|
|
|
|
|
|
|
}{ |
|
|
|
client = http.Client{} |
|
|
|
{"6-7", "Wo"}, |
|
|
|
response, err = client.Do(request) |
|
|
|
{"6-", "World"}, |
|
|
|
c.Assert(err, IsNil) |
|
|
|
{"-7", "o World"}, |
|
|
|
c.Assert(response.StatusCode, Equals, http.StatusPartialContent) |
|
|
|
} |
|
|
|
partialObject, err := ioutil.ReadAll(response.Body) |
|
|
|
for _, t := range table { |
|
|
|
c.Assert(err, IsNil) |
|
|
|
request, err = s.newRequest("GET", testAPIXLServer.URL+"/partial-content/bar", 0, nil) |
|
|
|
|
|
|
|
c.Assert(err, IsNil) |
|
|
|
c.Assert(string(partialObject), Equals, "Wo") |
|
|
|
request.Header.Add("Range", "bytes="+t.byteRange) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client = http.Client{} |
|
|
|
|
|
|
|
response, err = client.Do(request) |
|
|
|
|
|
|
|
c.Assert(err, IsNil) |
|
|
|
|
|
|
|
c.Assert(response.StatusCode, Equals, http.StatusPartialContent) |
|
|
|
|
|
|
|
partialObject, err := ioutil.ReadAll(response.Body) |
|
|
|
|
|
|
|
c.Assert(err, IsNil) |
|
|
|
|
|
|
|
c.Assert(string(partialObject), Equals, t.expectedString) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (s *MyAPIXLSuite) TestListObjectsHandlerErrors(c *C) { |
|
|
|
func (s *MyAPIXLSuite) TestListObjectsHandlerErrors(c *C) { |
|
|
|