From 93e0cae743270c310bc0c73d6235427760060789 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Fri, 5 Aug 2022 05:23:16 +0400 Subject: [PATCH] [#577] Fix version in GetObjectAttributes Signed-off-by: Angira Kekteeva --- api/handler/attributes.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/api/handler/attributes.go b/api/handler/attributes.go index eeab8ed82..069f160c9 100644 --- a/api/handler/attributes.go +++ b/api/handler/attributes.go @@ -98,21 +98,27 @@ func (h *handler) GetObjectAttributesHandler(w http.ResponseWriter, r *http.Requ return } + bktSettings, err := h.obj.GetBucketSettings(r.Context(), bktInfo) + if err != nil { + h.logAndSendError(w, "could not get bucket settings", reqInfo, err) + return + } + response, err := encodeToObjectAttributesResponse(info, params) if err != nil { h.logAndSendError(w, "couldn't encode object info to response", reqInfo, err) return } - writeAttributesHeaders(w.Header(), extendedInfo, params) + writeAttributesHeaders(w.Header(), extendedInfo, bktSettings.Unversioned()) if err = api.EncodeToResponse(w, response); err != nil { h.logAndSendError(w, "something went wrong", reqInfo, err) } } -func writeAttributesHeaders(h http.Header, info *data.ExtendedObjectInfo, params *GetObjectAttributesArgs) { +func writeAttributesHeaders(h http.Header, info *data.ExtendedObjectInfo, isBucketUnversioned bool) { h.Set(api.LastModified, info.ObjectInfo.Created.UTC().Format(http.TimeFormat)) - if len(params.VersionID) != 0 { + if !isBucketUnversioned { h.Set(api.AmzVersionID, info.Version()) }