mirror of
https://github.com/minio/minio.git
synced 2025-05-21 17:43:48 -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").
|
||||
HandlerFunc(s3APIMiddleware(api.PutObjectExtractHandler, traceHdrsS3HFlag))
|
||||
|
||||
// AppendObject to be rejected
|
||||
router.Methods(http.MethodPut).Path("/{object:.+}").
|
||||
HeadersRegexp(xhttp.AmzWriteOffsetBytes, "").
|
||||
HandlerFunc(s3APIMiddleware(errorResponseHandler))
|
||||
|
||||
// PutObject
|
||||
router.Methods(http.MethodPut).Path("/{object:.+}").
|
||||
HandlerFunc(s3APIMiddleware(api.PutObjectHandler, traceHdrsS3HFlag))
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"net/textproto"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/minio/madmin-go/v3"
|
||||
"github.com/minio/minio/internal/auth"
|
||||
@ -427,9 +428,31 @@ func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
|
||||
HTTPStatusCode: http.StatusUpgradeRequired,
|
||||
}, r.URL)
|
||||
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{
|
||||
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),
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
}, r.URL)
|
||||
|
@ -758,7 +758,7 @@ func (r *metacacheReader) Close() error {
|
||||
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 {
|
||||
wg sync.WaitGroup
|
||||
streamErr error
|
||||
|
@ -181,6 +181,9 @@ const (
|
||||
AmzChecksumTypeFullObject = "FULL_OBJECT"
|
||||
AmzChecksumTypeComposite = "COMPOSITE"
|
||||
|
||||
// S3 Express API related constant reject it.
|
||||
AmzWriteOffsetBytes = "x-amz-write-offset-bytes"
|
||||
|
||||
// Post Policy related
|
||||
AmzMetaUUID = "X-Amz-Meta-Uuid"
|
||||
AmzMetaName = "X-Amz-Meta-Name"
|
||||
|
Loading…
x
Reference in New Issue
Block a user