mirror of
https://github.com/minio/minio.git
synced 2025-05-22 01:53:55 -04:00
return error for AppendObject() API (#21272)
This commit is contained in:
parent
9ea14c88d8
commit
6d18dba9a2
@ -387,6 +387,11 @@ func registerAPIRouter(router *mux.Router) {
|
|||||||
HeadersRegexp(xhttp.AmzSnowballExtract, "true").
|
HeadersRegexp(xhttp.AmzSnowballExtract, "true").
|
||||||
HandlerFunc(s3APIMiddleware(api.PutObjectExtractHandler, traceHdrsS3HFlag))
|
HandlerFunc(s3APIMiddleware(api.PutObjectExtractHandler, traceHdrsS3HFlag))
|
||||||
|
|
||||||
|
// AppendObject to be rejected
|
||||||
|
router.Methods(http.MethodPut).Path("/{object:.+}").
|
||||||
|
HeadersRegexp(xhttp.AmzWriteOffsetBytes, "").
|
||||||
|
HandlerFunc(s3APIMiddleware(errorResponseHandler))
|
||||||
|
|
||||||
// PutObject
|
// PutObject
|
||||||
router.Methods(http.MethodPut).Path("/{object:.+}").
|
router.Methods(http.MethodPut).Path("/{object:.+}").
|
||||||
HandlerFunc(s3APIMiddleware(api.PutObjectHandler, traceHdrsS3HFlag))
|
HandlerFunc(s3APIMiddleware(api.PutObjectHandler, traceHdrsS3HFlag))
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"net/textproto"
|
"net/textproto"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/minio/madmin-go/v3"
|
"github.com/minio/madmin-go/v3"
|
||||||
"github.com/minio/minio/internal/auth"
|
"github.com/minio/minio/internal/auth"
|
||||||
@ -427,9 +428,31 @@ func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
HTTPStatusCode: http.StatusUpgradeRequired,
|
HTTPStatusCode: http.StatusUpgradeRequired,
|
||||||
}, r.URL)
|
}, r.URL)
|
||||||
default:
|
default:
|
||||||
|
defer logger.AuditLog(r.Context(), w, r, mustGetClaimsFromToken(r))
|
||||||
|
defer atomic.AddUint64(&globalHTTPStats.rejectedRequestsInvalid, 1)
|
||||||
|
|
||||||
|
// When we are not running in S3 Express mode, generate appropriate error
|
||||||
|
// for x-amz-write-offset HEADER specified.
|
||||||
|
if _, ok := r.Header[xhttp.AmzWriteOffsetBytes]; ok {
|
||||||
|
tc, ok := r.Context().Value(mcontext.ContextTraceKey).(*mcontext.TraceCtxt)
|
||||||
|
if ok {
|
||||||
|
tc.FuncName = "s3.AppendObject"
|
||||||
|
tc.ResponseRecorder.LogErrBody = true
|
||||||
|
}
|
||||||
|
|
||||||
|
writeErrorResponse(r.Context(), w, getAPIError(ErrNotImplemented), r.URL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tc, ok := r.Context().Value(mcontext.ContextTraceKey).(*mcontext.TraceCtxt)
|
||||||
|
if ok {
|
||||||
|
tc.FuncName = "s3.ValidRequest"
|
||||||
|
tc.ResponseRecorder.LogErrBody = true
|
||||||
|
}
|
||||||
|
|
||||||
writeErrorResponse(r.Context(), w, APIError{
|
writeErrorResponse(r.Context(), w, APIError{
|
||||||
Code: "BadRequest",
|
Code: "BadRequest",
|
||||||
Description: fmt.Sprintf("An error occurred when parsing the HTTP request %s at '%s'",
|
Description: fmt.Sprintf("An unsupported API call for method: %s at '%s'",
|
||||||
r.Method, r.URL.Path),
|
r.Method, r.URL.Path),
|
||||||
HTTPStatusCode: http.StatusBadRequest,
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
}, r.URL)
|
}, r.URL)
|
||||||
|
@ -758,7 +758,7 @@ func (r *metacacheReader) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// metacacheBlockWriter collects blocks and provides a callaback to store them.
|
// metacacheBlockWriter collects blocks and provides a callback to store them.
|
||||||
type metacacheBlockWriter struct {
|
type metacacheBlockWriter struct {
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
streamErr error
|
streamErr error
|
||||||
|
@ -181,6 +181,9 @@ const (
|
|||||||
AmzChecksumTypeFullObject = "FULL_OBJECT"
|
AmzChecksumTypeFullObject = "FULL_OBJECT"
|
||||||
AmzChecksumTypeComposite = "COMPOSITE"
|
AmzChecksumTypeComposite = "COMPOSITE"
|
||||||
|
|
||||||
|
// S3 Express API related constant reject it.
|
||||||
|
AmzWriteOffsetBytes = "x-amz-write-offset-bytes"
|
||||||
|
|
||||||
// Post Policy related
|
// Post Policy related
|
||||||
AmzMetaUUID = "X-Amz-Meta-Uuid"
|
AmzMetaUUID = "X-Amz-Meta-Uuid"
|
||||||
AmzMetaName = "X-Amz-Meta-Name"
|
AmzMetaName = "X-Amz-Meta-Name"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user