Skip to content

Commit

Permalink
incorporated review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Shubhendu Ram Tripathi <[email protected]>
  • Loading branch information
shtripat committed Feb 22, 2024
1 parent 73b2f70 commit 8159cb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api-compose-object.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (opts CopyDestOptions) Marshal(header http.Header) {
if opts.ReplaceMetadata {
header.Set("x-amz-metadata-directive", replaceDirective)
for k, v := range filterCustomMeta(opts.UserMetadata) {
if isAmzHeader(k) || isStandardHeader(k) || isStorageClassHeader(k) || isValidInternalHeader(k) {
if isAmzHeader(k) || isStandardHeader(k) || isStorageClassHeader(k) || isValidReplicationHeader(k) {
header.Set(k, v)
} else {
header.Set("x-amz-meta-"+k, v)
Expand Down
4 changes: 2 additions & 2 deletions api-put-object.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (opts PutObjectOptions) Header() (header http.Header) {
}

for k, v := range opts.UserMetadata {
if isAmzHeader(k) || isStandardHeader(k) || isStorageClassHeader(k) || isValidInternalHeader(k) {
if isAmzHeader(k) || isStandardHeader(k) || isStorageClassHeader(k) || isValidReplicationHeader(k) {
header.Set(k, v)
} else {
header.Set("x-amz-meta-"+k, v)
Expand All @@ -230,7 +230,7 @@ func (opts PutObjectOptions) Header() (header http.Header) {
// validate() checks if the UserMetadata map has standard headers or and raises an error if so.
func (opts PutObjectOptions) validate() (err error) {
for k, v := range opts.UserMetadata {
if !httpguts.ValidHeaderFieldName(k) || isStandardHeader(k) || isSSEHeader(k) || isStorageClassHeader(k) || isValidInternalHeader(k) {
if !httpguts.ValidHeaderFieldName(k) || isStandardHeader(k) || isSSEHeader(k) || isStorageClassHeader(k) || isValidReplicationHeader(k) {
return errInvalidArgument(k + " unsupported user defined metadata name")
}
if !httpguts.ValidHeaderFieldValue(v) {
Expand Down
16 changes: 8 additions & 8 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,18 +512,18 @@ func isAmzHeader(headerKey string) bool {
return strings.HasPrefix(key, "x-amz-meta-") || strings.HasPrefix(key, "x-amz-grant-") || key == "x-amz-acl" || isSSEHeader(headerKey) || strings.HasPrefix(key, "x-amz-checksum-")
}

var supportedInternalHeaders = map[string]bool{
"x-minio-internal-server-side-encryption-sealed-key": true,
"x-minio-internal-inline-data": true,
"x-minio-internal-server-side-encryption-seal-algorithm": true,
"x-minio-internal-server-side-encryption-iv": true,
var supportedReplicationHeaders = map[string]bool{
"x-minio-replication-server-side-encryption-sealed-key": true,
"x-minio-replication-inline-data": true,
"x-minio-replication-server-side-encryption-seal-algorithm": true,
"x-minio-replication-server-side-encryption-iv": true,
// Add more supported headers here.
// Must be lower case.
}

// isValidInternalHeader returns true if header is one of valid internal headers
func isValidInternalHeader(headerKey string) bool {
return supportedInternalHeaders[strings.ToLower(headerKey)]
// isValidReplicationHeader returns true if header is one of valid internal headers
func isValidReplicationHeader(headerKey string) bool {
return supportedReplicationHeaders[strings.ToLower(headerKey)]
}

// supportedQueryValues is a list of query strings that can be passed in when using GetObject.
Expand Down

0 comments on commit 8159cb3

Please sign in to comment.