4 "github.com/aws/aws-sdk-go/aws/client"
5 "github.com/aws/aws-sdk-go/aws/request"
6 "github.com/aws/aws-sdk-go/internal/s3err"
10 initClient = defaultInitClientFn
11 initRequest = defaultInitRequestFn
14 func defaultInitClientFn(c *client.Client) {
15 // Support building custom endpoints based on config
16 c.Handlers.Build.PushFront(updateEndpointForS3Config)
18 // Require SSL when using SSE keys
19 c.Handlers.Validate.PushBack(validateSSERequiresSSL)
20 c.Handlers.Build.PushBack(computeSSEKeys)
22 // S3 uses custom error unmarshaling logic
23 c.Handlers.UnmarshalError.Clear()
24 c.Handlers.UnmarshalError.PushBack(unmarshalError)
25 c.Handlers.UnmarshalError.PushBackNamed(s3err.RequestFailureWrapperHandler())
28 func defaultInitRequestFn(r *request.Request) {
29 // Add reuest handlers for specific platforms.
30 // e.g. 100-continue support for PUT requests using Go 1.6
31 platformRequestHandlers(r)
33 switch r.Operation.Name {
34 case opPutBucketCors, opPutBucketLifecycle, opPutBucketPolicy,
35 opPutBucketTagging, opDeleteObjects, opPutBucketLifecycleConfiguration,
36 opPutObjectLegalHold, opPutObjectRetention, opPutObjectLockConfiguration,
37 opPutBucketReplication:
38 // These S3 operations require Content-MD5 to be set
39 r.Handlers.Build.PushBack(contentMD5)
40 case opGetBucketLocation:
41 // GetBucketLocation has custom parsing logic
42 r.Handlers.Unmarshal.PushFront(buildGetBucketLocation)
44 // Auto-populate LocationConstraint with current region
45 r.Handlers.Validate.PushFront(populateLocationConstraint)
46 case opCopyObject, opUploadPartCopy, opCompleteMultipartUpload:
47 r.Handlers.Unmarshal.PushFront(copyMultipartStatusOKUnmarhsalError)
48 r.Handlers.Unmarshal.PushBackNamed(s3err.RequestFailureWrapperHandler())
49 case opPutObject, opUploadPart:
50 r.Handlers.Build.PushBack(computeBodyHashes)
51 // Disabled until #1837 root issue is resolved.
53 // r.Handlers.Build.PushBack(askForTxEncodingAppendMD5)
54 // r.Handlers.Unmarshal.PushBack(useMD5ValidationReader)
58 // bucketGetter is an accessor interface to grab the "Bucket" field from
60 type bucketGetter interface {
64 // sseCustomerKeyGetter is an accessor interface to grab the "SSECustomerKey"
65 // field from an S3 type.
66 type sseCustomerKeyGetter interface {
67 getSSECustomerKey() string
70 // copySourceSSECustomerKeyGetter is an accessor interface to grab the
71 // "CopySourceSSECustomerKey" field from an S3 type.
72 type copySourceSSECustomerKeyGetter interface {
73 getCopySourceSSECustomerKey() string