[#577] Add Version() to ExtendedObjectInfo

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2022-08-09 02:35:26 +04:00 committed by Kira
parent 3ac3f1cc9d
commit 37c46e926e
9 changed files with 27 additions and 22 deletions

View file

@ -71,14 +71,15 @@ func overrideResponseHeaders(h http.Header, query url.Values) {
}
}
func writeHeaders(h http.Header, info *data.ObjectInfo, tagSetLength int) {
func writeHeaders(h http.Header, extendedInfo *data.ExtendedObjectInfo, tagSetLength int) {
info := extendedInfo.ObjectInfo
if len(info.ContentType) > 0 && h.Get(api.ContentType) == "" {
h.Set(api.ContentType, info.ContentType)
}
h.Set(api.LastModified, info.Created.UTC().Format(http.TimeFormat))
h.Set(api.ContentLength, strconv.FormatInt(info.Size, 10))
h.Set(api.ETag, info.HashSum)
h.Set(api.AmzVersionID, info.ID.EncodeToString())
h.Set(api.AmzVersionID, extendedInfo.Version())
h.Set(api.AmzTaggingCount, strconv.Itoa(tagSetLength))
if cacheControl := info.Headers[api.CacheControl]; cacheControl != "" {
@ -159,7 +160,7 @@ func (h *handler) GetObjectHandler(w http.ResponseWriter, r *http.Request) {
return
}
writeHeaders(w.Header(), info, len(tagSet))
writeHeaders(w.Header(), extendedInfo, len(tagSet))
if params != nil {
writeRangeHeaders(w, params, info.Size)
} else {