@ -459,6 +459,8 @@ func testAPIPutObjectStreamSigV4Handler(obj ObjectLayer, instanceType, bucketNam
shouldPass bool
removeAuthHeader bool
fault streamFault
// Custom content encoding.
contentEncoding string
} {
// Test case - 1.
// Fetching the entire object and validating its contents.
@ -543,7 +545,7 @@ func testAPIPutObjectStreamSigV4Handler(obj ObjectLayer, instanceType, bucketNam
expectedRespStatus : http . StatusOK ,
accessKey : credentials . AccessKey ,
secretKey : credentials . SecretKey ,
shouldPass : fals e,
shouldPass : tru e,
} ,
// Test case - 7
// Chunk with malformed encoding.
@ -621,6 +623,21 @@ func testAPIPutObjectStreamSigV4Handler(obj ObjectLayer, instanceType, bucketNam
shouldPass : false ,
fault : tooBigDecodedLength ,
} ,
// Test case - 12
// Set custom content encoding should succeed and save the encoding properly.
{
bucketName : bucketName ,
objectName : objectName ,
data : bytesData ,
dataLen : len ( bytesData ) ,
chunkSize : 100 * humanize . KiByte ,
expectedContent : [ ] byte { } ,
expectedRespStatus : http . StatusOK ,
accessKey : credentials . AccessKey ,
secretKey : credentials . SecretKey ,
shouldPass : true ,
contentEncoding : "aws-chunked,gzip" ,
} ,
}
// Iterating over the cases, fetching the object validating the response.
for i , testCase := range testCases {
@ -634,11 +651,16 @@ func testAPIPutObjectStreamSigV4Handler(obj ObjectLayer, instanceType, bucketNam
int64 ( testCase . dataLen ) , testCase . chunkSize , bytes . NewReader ( testCase . data ) ,
testCase . accessKey , testCase . secretKey )
} else {
} else if testCase . contentEncoding == "" {
req , err = newTestStreamingSignedRequest ( "PUT" ,
getPutObjectURL ( "" , testCase . bucketName , testCase . objectName ) ,
int64 ( testCase . dataLen ) , testCase . chunkSize , bytes . NewReader ( testCase . data ) ,
testCase . accessKey , testCase . secretKey )
} else if testCase . contentEncoding != "" {
req , err = newTestStreamingSignedCustomEncodingRequest ( "PUT" ,
getPutObjectURL ( "" , testCase . bucketName , testCase . objectName ) ,
int64 ( testCase . dataLen ) , testCase . chunkSize , bytes . NewReader ( testCase . data ) ,
testCase . accessKey , testCase . secretKey , testCase . contentEncoding )
}
if err != nil {
t . Fatalf ( "Test %d: Failed to create HTTP request for Put Object: <ERROR> %v" , i + 1 , err )
@ -681,7 +703,6 @@ func testAPIPutObjectStreamSigV4Handler(obj ObjectLayer, instanceType, bucketNam
t . Errorf ( "Test %d: %s: Object content differs from expected value.: %s" , i + 1 , instanceType , string ( actualContent ) )
continue
}
objInfo , err := obj . GetObjectInfo ( testCase . bucketName , testCase . objectName )
if err != nil {
t . Fatalf ( "Test %d: %s: Failed to fetch the copied object: <ERROR> %s" , i + 1 , instanceType , err )
@ -689,6 +710,10 @@ func testAPIPutObjectStreamSigV4Handler(obj ObjectLayer, instanceType, bucketNam
if objInfo . ContentEncoding == streamingContentEncoding {
t . Fatalf ( "Test %d: %s: ContentEncoding is set to \"aws-chunked\" which is unexpected" , i + 1 , instanceType )
}
expectedContentEncoding := trimAwsChunkedContentEncoding ( testCase . contentEncoding )
if expectedContentEncoding != objInfo . ContentEncoding {
t . Fatalf ( "Test %d: %s: ContentEncoding is set to \"%s\" which is unexpected, expected \"%s\"" , i + 1 , instanceType , objInfo . ContentEncoding , expectedContentEncoding )
}
buffer := new ( bytes . Buffer )
err = obj . GetObject ( testCase . bucketName , testCase . objectName , 0 , int64 ( testCase . dataLen ) , buffer )
if err != nil {