return x-amz-tag-count header when GET object.

This commit is contained in:
ruitao.liu 2020-10-27 16:49:31 +08:00
parent 44921220b0
commit 19026ae55d
2 changed files with 14 additions and 1 deletions

View file

@ -7,7 +7,7 @@ import (
) )
const ( const (
S3TAG_PREFIX = "s3-" S3TAG_PREFIX = "s3-tag-"
) )
func (s3a *S3ApiServer) getTags(parentDirectoryPath string, entryName string) (tags map[string]string, err error) { func (s3a *S3ApiServer) getTags(parentDirectoryPath string, entryName string) (tags map[string]string, err error) {

View file

@ -93,6 +93,19 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
} }
} }
//set tag count
if r.Method == "GET" {
tagCount := 0
for k, _ := range entry.Extended {
if strings.HasPrefix(k, "s3-tag-") {
tagCount++
}
}
if tagCount > 0 {
w.Header().Set("x-amz-tag-count", strconv.Itoa(tagCount))
}
}
// set etag // set etag
etag := filer.ETagEntry(entry) etag := filer.ETagEntry(entry)
if inm := r.Header.Get("If-None-Match"); inm == "\""+etag+"\"" { if inm := r.Header.Get("If-None-Match"); inm == "\""+etag+"\"" {