[#619] Filter system metadata

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2022-07-26 05:08:25 +04:00 committed by Alex Vanin
parent 4380406602
commit 4483c6f57a
2 changed files with 22 additions and 10 deletions

View file

@ -2,15 +2,16 @@ package api
// Standard S3 HTTP request/response constants. // Standard S3 HTTP request/response constants.
const ( const (
MetadataPrefix = "X-Amz-Meta-" MetadataPrefix = "X-Amz-Meta-"
AmzMetadataDirective = "X-Amz-Metadata-Directive" NeoFSSystemMetadataPrefix = "S3-"
AmzVersionID = "X-Amz-Version-Id" AmzMetadataDirective = "X-Amz-Metadata-Directive"
AmzTaggingCount = "X-Amz-Tagging-Count" AmzVersionID = "X-Amz-Version-Id"
AmzTagging = "X-Amz-Tagging" AmzTaggingCount = "X-Amz-Tagging-Count"
AmzDeleteMarker = "X-Amz-Delete-Marker" AmzTagging = "X-Amz-Tagging"
AmzCopySource = "X-Amz-Copy-Source" AmzDeleteMarker = "X-Amz-Delete-Marker"
AmzCopySourceRange = "X-Amz-Copy-Source-Range" AmzCopySource = "X-Amz-Copy-Source"
AmzDate = "X-Amz-Date" AmzCopySourceRange = "X-Amz-Copy-Source-Range"
AmzDate = "X-Amz-Date"
LastModified = "Last-Modified" LastModified = "Last-Modified"
Date = "Date" Date = "Date"
@ -88,3 +89,13 @@ var ResponseModifiers = map[string]string{
"response-content-disposition": ContentDisposition, "response-content-disposition": ContentDisposition,
"response-content-encoding": ContentEncoding, "response-content-encoding": ContentEncoding,
} }
var SystemMetadata = map[string]struct{}{
Date: {},
CacheControl: {},
ContentDisposition: {},
ContentLength: {},
ContentType: {},
LastModified: {},
ETag: {},
}

View file

@ -613,7 +613,8 @@ func (n *layer) getAllObjectsVersions(ctx context.Context, bkt *data.BucketInfo,
} }
func IsSystemHeader(key string) bool { func IsSystemHeader(key string) bool {
return strings.HasPrefix(key, "S3-") _, ok := api.SystemMetadata[key]
return ok || strings.HasPrefix(key, api.NeoFSSystemMetadataPrefix)
} }
func shouldSkip(node *data.NodeVersion, p allObjectParams, existed map[string]struct{}) bool { func shouldSkip(node *data.NodeVersion, p allObjectParams, existed map[string]struct{}) bool {