|
|
|
@ -116,7 +116,7 @@ func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r |
|
|
|
|
// get gateway encryption options
|
|
|
|
|
opts, err := getOpts(ctx, r, bucket, object) |
|
|
|
|
if err != nil { |
|
|
|
|
writeErrorResponseHeadersOnly(w, toAPIError(ctx, err)) |
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -192,6 +192,14 @@ func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r |
|
|
|
|
|
|
|
|
|
objInfo, err := getObjectInfo(ctx, bucket, object, opts) |
|
|
|
|
if err != nil { |
|
|
|
|
if globalBucketVersioningSys.Enabled(bucket) { |
|
|
|
|
// Versioning enabled quite possibly object is deleted might be delete-marker
|
|
|
|
|
// if present set the headers, no idea why AWS S3 sets these headers.
|
|
|
|
|
if objInfo.VersionID != "" && objInfo.DeleteMarker { |
|
|
|
|
w.Header()[xhttp.AmzVersionID] = []string{objInfo.VersionID} |
|
|
|
|
w.Header()[xhttp.AmzDeleteMarker] = []string{strconv.FormatBool(objInfo.DeleteMarker)} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -256,7 +264,7 @@ func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r |
|
|
|
|
case crypto.SSEC.IsEncrypted(objInfo.UserDefined): |
|
|
|
|
// Validate the SSE-C Key set in the header.
|
|
|
|
|
if _, err = crypto.SSEC.UnsealObjectKey(r.Header, objInfo.UserDefined, bucket, object); err != nil { |
|
|
|
|
writeErrorResponseHeadersOnly(w, toAPIError(ctx, err)) |
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
w.Header().Set(crypto.SSECAlgorithm, r.Header.Get(crypto.SSECAlgorithm)) |
|
|
|
@ -313,7 +321,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
|
// get gateway encryption options
|
|
|
|
|
opts, err := getOpts(ctx, r, bucket, object) |
|
|
|
|
if err != nil { |
|
|
|
|
writeErrorResponseHeadersOnly(w, toAPIError(ctx, err)) |
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -379,6 +387,14 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
|
|
|
|
|
|
gr, err := getObjectNInfo(ctx, bucket, object, rs, r.Header, readLock, opts) |
|
|
|
|
if err != nil { |
|
|
|
|
if globalBucketVersioningSys.Enabled(bucket) && gr != nil { |
|
|
|
|
// Versioning enabled quite possibly object is deleted might be delete-marker
|
|
|
|
|
// if present set the headers, no idea why AWS S3 sets these headers.
|
|
|
|
|
if gr.ObjInfo.VersionID != "" && gr.ObjInfo.DeleteMarker { |
|
|
|
|
w.Header()[xhttp.AmzVersionID] = []string{gr.ObjInfo.VersionID} |
|
|
|
|
w.Header()[xhttp.AmzDeleteMarker] = []string{strconv.FormatBool(gr.ObjInfo.DeleteMarker)} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -435,6 +451,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
|
statusCodeWritten = true |
|
|
|
|
w.WriteHeader(http.StatusPartialContent) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Write object content to response body
|
|
|
|
|
if _, err = io.Copy(httpWriter, gr); err != nil { |
|
|
|
|
if !httpWriter.HasWritten() && !statusCodeWritten { // write error response only if no data or headers has been written to client yet
|
|
|
|
@ -552,6 +569,14 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
|
|
|
|
|
|
objInfo, err := getObjectInfo(ctx, bucket, object, opts) |
|
|
|
|
if err != nil { |
|
|
|
|
if globalBucketVersioningSys.Enabled(bucket) { |
|
|
|
|
// Versioning enabled quite possibly object is deleted might be delete-marker
|
|
|
|
|
// if present set the headers, no idea why AWS S3 sets these headers.
|
|
|
|
|
if objInfo.VersionID != "" && objInfo.DeleteMarker { |
|
|
|
|
w.Header()[xhttp.AmzVersionID] = []string{objInfo.VersionID} |
|
|
|
|
w.Header()[xhttp.AmzDeleteMarker] = []string{strconv.FormatBool(objInfo.DeleteMarker)} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
writeErrorResponseHeadersOnly(w, toAPIError(ctx, err)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -861,6 +886,14 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
|
if isErrPreconditionFailed(err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if globalBucketVersioningSys.Enabled(srcBucket) && gr != nil { |
|
|
|
|
// Versioning enabled quite possibly object is deleted might be delete-marker
|
|
|
|
|
// if present set the headers, no idea why AWS S3 sets these headers.
|
|
|
|
|
if gr.ObjInfo.VersionID != "" && gr.ObjInfo.DeleteMarker { |
|
|
|
|
w.Header()[xhttp.AmzVersionID] = []string{gr.ObjInfo.VersionID} |
|
|
|
|
w.Header()[xhttp.AmzDeleteMarker] = []string{strconv.FormatBool(gr.ObjInfo.DeleteMarker)} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -1408,7 +1441,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
|
var opts ObjectOptions |
|
|
|
|
opts, err = putOpts(ctx, r, bucket, object, metadata) |
|
|
|
|
if err != nil { |
|
|
|
|
writeErrorResponseHeadersOnly(w, toAPIError(ctx, err)) |
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1620,7 +1653,7 @@ func (api objectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r |
|
|
|
|
|
|
|
|
|
opts, err := putOpts(ctx, r, bucket, object, metadata) |
|
|
|
|
if err != nil { |
|
|
|
|
writeErrorResponseHeadersOnly(w, toAPIError(ctx, err)) |
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
newMultipartUpload := objectAPI.NewMultipartUpload |
|
|
|
@ -1771,6 +1804,14 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt |
|
|
|
|
if isErrPreconditionFailed(err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if globalBucketVersioningSys.Enabled(srcBucket) && gr != nil { |
|
|
|
|
// Versioning enabled quite possibly object is deleted might be delete-marker
|
|
|
|
|
// if present set the headers, no idea why AWS S3 sets these headers.
|
|
|
|
|
if gr.ObjInfo.VersionID != "" && gr.ObjInfo.DeleteMarker { |
|
|
|
|
w.Header()[xhttp.AmzVersionID] = []string{gr.ObjInfo.VersionID} |
|
|
|
|
w.Header()[xhttp.AmzDeleteMarker] = []string{strconv.FormatBool(gr.ObjInfo.DeleteMarker)} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|