mirror of
https://github.com/minio/minio.git
synced 2025-01-23 12:43:16 -05:00
Merge pull request #56 from harshavardhana/pr_out_return_http_statusnotimplemented_for_range_of_bucket_and_object_resources
This commit is contained in:
commit
44f43809d7
@ -59,3 +59,24 @@ type Owner struct {
|
||||
ID string
|
||||
DisplayName string
|
||||
}
|
||||
|
||||
var unimplementedBucketResourceNames = map[string]bool{
|
||||
"acl": true,
|
||||
"lifecycle": true,
|
||||
"policy": true,
|
||||
"location": true,
|
||||
"logging": true,
|
||||
"notification": true,
|
||||
"versions": true,
|
||||
"requestPayment": true,
|
||||
"versioning": true,
|
||||
"website": true,
|
||||
"uploads": true,
|
||||
}
|
||||
|
||||
var unimplementedObjectResourceNames = map[string]bool{
|
||||
"uploadId": true,
|
||||
"acl": true,
|
||||
"torrent": true,
|
||||
"uploads": true,
|
||||
}
|
||||
|
@ -64,7 +64,32 @@ func HttpHandler(storage mstorage.Storage) http.Handler {
|
||||
return mux
|
||||
}
|
||||
|
||||
func (server *minioApi) ignoreUnImplementedBucketResources(req *http.Request) bool {
|
||||
q := req.URL.Query()
|
||||
for name := range q {
|
||||
if unimplementedBucketResourceNames[name] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (server *minioApi) ignoreUnImplementedObjectResources(req *http.Request) bool {
|
||||
q := req.URL.Query()
|
||||
for name := range q {
|
||||
if unimplementedObjectResourceNames[name] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (server *minioApi) getObjectHandler(w http.ResponseWriter, req *http.Request) {
|
||||
if server.ignoreUnImplementedObjectResources(req) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
vars := mux.Vars(req)
|
||||
bucket := vars["bucket"]
|
||||
object := vars["object"]
|
||||
@ -111,6 +136,11 @@ func (server *minioApi) headObjectHandler(w http.ResponseWriter, req *http.Reque
|
||||
}
|
||||
|
||||
func (server *minioApi) listBucketsHandler(w http.ResponseWriter, req *http.Request) {
|
||||
if server.ignoreUnImplementedBucketResources(req) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
vars := mux.Vars(req)
|
||||
prefix, ok := vars["prefix"]
|
||||
if !ok {
|
||||
@ -140,6 +170,11 @@ func (server *minioApi) listBucketsHandler(w http.ResponseWriter, req *http.Requ
|
||||
}
|
||||
|
||||
func (server *minioApi) listObjectsHandler(w http.ResponseWriter, req *http.Request) {
|
||||
if server.ignoreUnImplementedObjectResources(req) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
vars := mux.Vars(req)
|
||||
bucket := vars["bucket"]
|
||||
prefix, ok := vars["prefix"]
|
||||
@ -172,6 +207,11 @@ func (server *minioApi) listObjectsHandler(w http.ResponseWriter, req *http.Requ
|
||||
}
|
||||
|
||||
func (server *minioApi) putObjectHandler(w http.ResponseWriter, req *http.Request) {
|
||||
if server.ignoreUnImplementedBucketResources(req) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
vars := mux.Vars(req)
|
||||
bucket := vars["bucket"]
|
||||
object := vars["object"]
|
||||
@ -184,6 +224,11 @@ func (server *minioApi) putObjectHandler(w http.ResponseWriter, req *http.Reques
|
||||
}
|
||||
|
||||
func (server *minioApi) putBucketHandler(w http.ResponseWriter, req *http.Request) {
|
||||
if server.ignoreUnImplementedBucketResources(req) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
vars := mux.Vars(req)
|
||||
bucket := vars["bucket"]
|
||||
err := server.storage.StoreBucket(bucket)
|
||||
|
@ -174,6 +174,17 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
||||
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello three")))
|
||||
}
|
||||
|
||||
func (s *MySuite) TestNotImplemented(c *C) {
|
||||
_, _, storage := inmemory.Start()
|
||||
httpHandler := HttpHandler(storage)
|
||||
testServer := httptest.NewServer(httpHandler)
|
||||
defer testServer.Close()
|
||||
|
||||
response, err := http.Get(testServer.URL + "/bucket/object?acl")
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(response.StatusCode, Equals, http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
func (s *MySuite) TestHeader(c *C) {
|
||||
_, _, storage := inmemory.Start()
|
||||
httpHandler := HttpHandler(storage)
|
||||
|
Loading…
x
Reference in New Issue
Block a user