fix: Better check of RPC type requests (#6927)

guessIsRPCReq() considers all POST requests as RPC but doesn't
check if this is an object operation API or not, which is actually
confusing bucket forwarder handler when it receives a new multipart
upload API which is a POST http request.

Due to this bug, users having a federated setup are not able to
upload a multipart object using an endpoint which doesn't actually
contain the specified bucket that will store the object.

Hence this commit will fix the described issue.
master
Anis Elleuch 6 years ago committed by kannappanr
parent f6980c4630
commit 40852801ea
  1. 3
      cmd/generic-handlers.go
  2. 7
      cmd/generic-handlers_test.go

@ -228,7 +228,8 @@ func guessIsRPCReq(req *http.Request) bool {
if req == nil { if req == nil {
return false return false
} }
return req.Method == http.MethodPost return req.Method == http.MethodPost &&
strings.HasPrefix(req.URL.Path, minioReservedBucketPath+"/")
} }
func (h redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

@ -78,9 +78,16 @@ func TestGuessIsRPC(t *testing.T) {
if guessIsRPCReq(nil) { if guessIsRPCReq(nil) {
t.Fatal("Unexpected return for nil request") t.Fatal("Unexpected return for nil request")
} }
u, err := url.Parse("http://localhost:9000/minio/lock")
if err != nil {
t.Fatal(err)
}
r := &http.Request{ r := &http.Request{
Proto: "HTTP/1.0", Proto: "HTTP/1.0",
Method: http.MethodPost, Method: http.MethodPost,
URL: u,
} }
if !guessIsRPCReq(r) { if !guessIsRPCReq(r) {
t.Fatal("Test shouldn't fail for a possible net/rpc request.") t.Fatal("Test shouldn't fail for a possible net/rpc request.")

Loading…
Cancel
Save