|
@ -2,7 +2,7 @@ package s3api |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"fmt" |
|
|
"fmt" |
|
|
headers "github.com/chrislusf/seaweedfs/weed/s3api/http" |
|
|
|
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/s3api/s3_constants" |
|
|
"net/http" |
|
|
"net/http" |
|
|
"reflect" |
|
|
"reflect" |
|
|
"sort" |
|
|
"sort" |
|
@ -58,7 +58,7 @@ var processMetadataTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{ |
|
|
H{ |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
@ -74,7 +74,7 @@ var processMetadataTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=existing", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=existing", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -84,7 +84,7 @@ var processMetadataTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{ |
|
|
H{ |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
@ -100,7 +100,7 @@ var processMetadataTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -110,8 +110,8 @@ var processMetadataTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{ |
|
|
H{ |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
@ -128,8 +128,8 @@ var processMetadataTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -139,8 +139,8 @@ var processMetadataTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{}, |
|
|
H{}, |
|
|
H{}, |
|
|
H{}, |
|
@ -148,8 +148,8 @@ var processMetadataTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -157,8 +157,8 @@ var processMetadataTestCases = []struct { |
|
|
206, |
|
|
206, |
|
|
H{ |
|
|
H{ |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{ |
|
|
H{ |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
@ -173,8 +173,8 @@ var processMetadataTestCases = []struct { |
|
|
}, |
|
|
}, |
|
|
H{ |
|
|
H{ |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -183,8 +183,8 @@ var processMetadataTestCases = []struct { |
|
|
H{ |
|
|
H{ |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{ |
|
|
H{ |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
@ -200,8 +200,8 @@ var processMetadataTestCases = []struct { |
|
|
H{ |
|
|
H{ |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
@ -238,7 +238,7 @@ var processMetadataBytesTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{ |
|
|
H{ |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
@ -260,7 +260,7 @@ var processMetadataBytesTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{ |
|
|
H{ |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
@ -282,8 +282,8 @@ var processMetadataBytesTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{ |
|
|
H{ |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
@ -303,8 +303,8 @@ var processMetadataBytesTestCases = []struct { |
|
|
105, |
|
|
105, |
|
|
H{ |
|
|
H{ |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{ |
|
|
H{ |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
|
"X-Amz-Meta-My-Meta": "existing", |
|
@ -321,8 +321,8 @@ var processMetadataBytesTestCases = []struct { |
|
|
"User-Agent": "firefox", |
|
|
"User-Agent": "firefox", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Meta-My-Meta": "request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
"X-Amz-Tagging": "A=B&a=b&type=request", |
|
|
headers.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
headers.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
|
|
|
|
|
|
s3_constants.AmzUserMetaDirective: DirectiveReplace, |
|
|
|
|
|
s3_constants.AmzObjectTaggingDirective: DirectiveReplace, |
|
|
}, |
|
|
}, |
|
|
H{}, |
|
|
H{}, |
|
|
H{ |
|
|
H{ |
|
@ -385,10 +385,10 @@ func TestProcessMetadataBytes(t *testing.T) { |
|
|
|
|
|
|
|
|
func fmtTagging(maps ...map[string]string) { |
|
|
func fmtTagging(maps ...map[string]string) { |
|
|
for _, m := range maps { |
|
|
for _, m := range maps { |
|
|
if tagging := m[headers.AmzObjectTagging]; len(tagging) > 0 { |
|
|
|
|
|
|
|
|
if tagging := m[s3_constants.AmzObjectTagging]; len(tagging) > 0 { |
|
|
split := strings.Split(tagging, "&") |
|
|
split := strings.Split(tagging, "&") |
|
|
sort.Strings(split) |
|
|
sort.Strings(split) |
|
|
m[headers.AmzObjectTagging] = strings.Join(split, "&") |
|
|
|
|
|
|
|
|
m[s3_constants.AmzObjectTagging] = strings.Join(split, "&") |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|