From 7b3336326245b20b2939209ffce4842f85b4b49d Mon Sep 17 00:00:00 2001 From: zveinn Date: Mon, 8 Jan 2024 13:44:47 +0000 Subject: [PATCH] Adding a header check for compatibility support --- api-get-object-attributes.go | 7 +++++++ constants.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/api-get-object-attributes.go b/api-get-object-attributes.go index 1dcd20aef1..7f0b55fa6d 100644 --- a/api-get-object-attributes.go +++ b/api-get-object-attributes.go @@ -19,6 +19,7 @@ package minio import ( "context" "encoding/xml" + "errors" "net/http" "net/url" "strconv" @@ -173,8 +174,14 @@ func (c *Client) GetObjectAttributes(ctx context.Context, bucketName, objectName if err != nil { return ObjectAttributes{}, err } + defer closeResponse(resp) + hasEtag := resp.Header.Get(Etag) + if hasEtag != "" { + return ObjectAttributes{}, errors.New("getObjectAttributes is not supported by the current endpoint version") + } + if resp.StatusCode != http.StatusOK { ER := new(ErrorResponse) if err := xml.NewDecoder(resp.Body).Decode(ER); err != nil { diff --git a/constants.go b/constants.go index 3d55c0e56e..5d9827dfc9 100644 --- a/constants.go +++ b/constants.go @@ -69,6 +69,8 @@ const ( ) const ( + // Response Headers + Etag = "ETag" // Storage class header. amzStorageClass = "X-Amz-Storage-Class"