From 84508a17067ac2a9379703e31426ad71ab5bf6b6 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Mon, 23 Aug 2021 11:37:08 +0300 Subject: [PATCH] [#220] Add cid to HeadBucket response Signed-off-by: Denis Kirillov --- api/handler/head.go | 4 +++- api/headers.go | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/handler/head.go b/api/handler/head.go index 410e0516c..3db3db500 100644 --- a/api/handler/head.go +++ b/api/handler/head.go @@ -54,10 +54,12 @@ func (h *handler) HeadObjectHandler(w http.ResponseWriter, r *http.Request) { func (h *handler) HeadBucketHandler(w http.ResponseWriter, r *http.Request) { reqInfo := api.GetReqInfo(r.Context()) - if _, err := h.obj.GetBucketInfo(r.Context(), reqInfo.BucketName); err != nil { + bktInfo, err := h.obj.GetBucketInfo(r.Context(), reqInfo.BucketName) + if err != nil { h.logAndSendError(w, "could not fetch object info", reqInfo, err) return } + w.Header().Set(api.ContainerID, bktInfo.CID.String()) api.WriteResponse(w, http.StatusOK, nil, api.MimeNone) } diff --git a/api/headers.go b/api/headers.go index 7717d6936..c75f71522 100644 --- a/api/headers.go +++ b/api/headers.go @@ -39,4 +39,6 @@ const ( AmzGrantRead = "X-Amz-Grant-Read" AmzGrantWrite = "X-Amz-Grant-Write" AmzExpectedBucketOwner = "X-Amz-Expected-Bucket-Owner" + + ContainerID = "X-Container-Id" )