diff --git a/cmd/api-router.go b/cmd/api-router.go index 95360945c..e09b7bc25 100644 --- a/cmd/api-router.go +++ b/cmd/api-router.go @@ -434,8 +434,9 @@ func registerAPIRouter(router *mux.Router) { router.Methods(http.MethodHead).HandlerFunc( collectAPIStats("headbucket", maxClients(gz(httpTraceAll(api.HeadBucketHandler))))) // PostPolicy - router.Methods(http.MethodPost).HeadersRegexp(xhttp.ContentType, "multipart/form-data*").HandlerFunc( - collectAPIStats("postpolicybucket", maxClients(gz(httpTraceHdrs(api.PostPolicyBucketHandler))))) + router.Methods(http.MethodPost).MatcherFunc(func(r *http.Request, _ *mux.RouteMatch) bool { + return isRequestPostPolicySignatureV4(r) + }).HandlerFunc(collectAPIStats("postpolicybucket", maxClients(gz(httpTraceHdrs(api.PostPolicyBucketHandler))))) // DeleteMultipleObjects router.Methods(http.MethodPost).HandlerFunc( collectAPIStats("deletemultipleobjects", maxClients(gz(httpTraceAll(api.DeleteMultipleObjectsHandler))))).Queries("delete", "") diff --git a/cmd/auth-handler.go b/cmd/auth-handler.go index addf5a7b7..947b8ee9d 100644 --- a/cmd/auth-handler.go +++ b/cmd/auth-handler.go @@ -25,6 +25,7 @@ import ( "encoding/hex" "errors" "io" + "mime" "net/http" "net/url" "strconv" @@ -74,8 +75,11 @@ func isRequestPresignedSignatureV2(r *http.Request) bool { // Verify if request has AWS Post policy Signature Version '4'. func isRequestPostPolicySignatureV4(r *http.Request) bool { - return strings.Contains(r.Header.Get(xhttp.ContentType), "multipart/form-data") && - r.Method == http.MethodPost + mediaType, _, err := mime.ParseMediaType(r.Header.Get(xhttp.ContentType)) + if err != nil { + return false + } + return mediaType == "multipart/form-data" && r.Method == http.MethodPost } // Verify if the request has AWS Streaming Signature Version '4'. This is only valid for 'PUT' operation.