mirror of https://github.com/minio/minio.git
parent
3d3b75fb8d
commit
2c372a9894
|
@ -68,6 +68,13 @@ func encodeResponseJSON(response interface{}) []byte {
|
||||||
return bytesBuffer.Bytes()
|
return bytesBuffer.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write parts count
|
||||||
|
func setPartsCountHeaders(w http.ResponseWriter, objInfo ObjectInfo) {
|
||||||
|
if strings.Contains(objInfo.ETag, "-") && len(objInfo.Parts) > 0 {
|
||||||
|
w.Header()[xhttp.AmzMpPartsCount] = []string{strconv.Itoa(len(objInfo.Parts))}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Write object header
|
// Write object header
|
||||||
func setObjectHeaders(w http.ResponseWriter, objInfo ObjectInfo, rs *HTTPRangeSpec) (err error) {
|
func setObjectHeaders(w http.ResponseWriter, objInfo ObjectInfo, rs *HTTPRangeSpec) (err error) {
|
||||||
// set common headers
|
// set common headers
|
||||||
|
@ -82,10 +89,6 @@ func setObjectHeaders(w http.ResponseWriter, objInfo ObjectInfo, rs *HTTPRangeSp
|
||||||
w.Header()[xhttp.ETag] = []string{"\"" + objInfo.ETag + "\""}
|
w.Header()[xhttp.ETag] = []string{"\"" + objInfo.ETag + "\""}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(objInfo.ETag, "-") && len(objInfo.Parts) > 0 {
|
|
||||||
w.Header()[xhttp.AmzMpPartsCount] = []string{strconv.Itoa(len(objInfo.Parts))}
|
|
||||||
}
|
|
||||||
|
|
||||||
if objInfo.ContentType != "" {
|
if objInfo.ContentType != "" {
|
||||||
w.Header().Set(xhttp.ContentType, objInfo.ContentType)
|
w.Header().Set(xhttp.ContentType, objInfo.ContentType)
|
||||||
}
|
}
|
||||||
|
|
|
@ -903,7 +903,7 @@ func getOpts(ctx context.Context, r *http.Request, bucket, object string) (Objec
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return opts, err
|
return opts, err
|
||||||
}
|
}
|
||||||
if partNumber < 0 {
|
if partNumber <= 0 {
|
||||||
return opts, errInvalidArgument
|
return opts, errInvalidArgument
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,9 +173,9 @@ func checkPreconditions(ctx context.Context, w http.ResponseWriter, r *http.Requ
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the part number is correct.
|
// Check if the part number is correct.
|
||||||
if opts.PartNumber > 0 && len(objInfo.Parts) > 0 && opts.PartNumber != len(objInfo.Parts) {
|
if opts.PartNumber > 1 && opts.PartNumber > len(objInfo.Parts) {
|
||||||
writeHeaders()
|
writeHeaders()
|
||||||
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrPreconditionFailed), r.URL, guessIsBrowserReq(r))
|
w.WriteHeader(http.StatusRequestedRangeNotSatisfiable)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -426,6 +426,11 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set Parts Count Header
|
||||||
|
if opts.PartNumber > 0 && len(objInfo.Parts) > 0 {
|
||||||
|
setPartsCountHeaders(w, objInfo)
|
||||||
|
}
|
||||||
|
|
||||||
setHeadGetRespHeaders(w, r.URL.Query())
|
setHeadGetRespHeaders(w, r.URL.Query())
|
||||||
setAmzExpirationHeader(w, bucket, objInfo)
|
setAmzExpirationHeader(w, bucket, objInfo)
|
||||||
|
|
||||||
|
@ -604,6 +609,11 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set Parts Count Header
|
||||||
|
if opts.PartNumber > 0 && len(objInfo.Parts) > 0 {
|
||||||
|
setPartsCountHeaders(w, objInfo)
|
||||||
|
}
|
||||||
|
|
||||||
// Set any additional requested response headers.
|
// Set any additional requested response headers.
|
||||||
setHeadGetRespHeaders(w, r.URL.Query())
|
setHeadGetRespHeaders(w, r.URL.Query())
|
||||||
|
|
||||||
|
|
|
@ -1310,6 +1310,11 @@ func (web *webAPIHandlers) Download(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set Parts Count Header
|
||||||
|
if opts.PartNumber > 0 && len(objInfo.Parts) > 0 {
|
||||||
|
setPartsCountHeaders(w, objInfo)
|
||||||
|
}
|
||||||
|
|
||||||
if err = setObjectHeaders(w, objInfo, nil); err != nil {
|
if err = setObjectHeaders(w, objInfo, nil); err != nil {
|
||||||
writeWebErrorResponse(w, err)
|
writeWebErrorResponse(w, err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue