@@ -563,9 +563,6 @@ type requestMetadata struct {
563563 trailer http.Header // (http.Request).Trailer. Requires v4 signature.
564564
565565 expect200OKWithError bool
566-
567- // s3 operation name
568- s3Operation string
569566}
570567
571568// dumpHTTP - dump HTTP request and response.
@@ -721,16 +718,11 @@ func (c *Client) executeMethod(ctx context.Context, method string, metadata requ
721718 metadata .trailer .Set (metadata .addCrc .Key (), base64 .StdEncoding .EncodeToString (crc .Sum (nil )))
722719 }
723720
724- opt := metadata .s3Operation
725- if opt == "" {
726- opt = resolveS3Operation (method , metadata )
727- }
728- metadata .s3Operation = opt
729-
730721 execCtx := ExecutionContext {
731- Operation : opt ,
732- BucketName : metadata .bucketName ,
733- ObjectName : metadata .objectName ,
722+ Method : method ,
723+ BucketName : metadata .bucketName ,
724+ ObjectName : metadata .objectName ,
725+ QueryValues : metadata .queryValues ,
734726 }
735727
736728 for _ , m := range c .middlewares {
@@ -946,12 +938,10 @@ func (c *Client) newRequest(ctx context.Context, method string, metadata request
946938 return nil , err
947939 }
948940 execCtx := ExecutionContext {
949- Operation : metadata .s3Operation ,
950- BucketName : metadata .bucketName ,
951- ObjectName : metadata .objectName ,
952- }
953- if execCtx .Operation == "" {
954- execCtx .Operation = resolveS3Operation (method , metadata )
941+ Method : method ,
942+ BucketName : metadata .bucketName ,
943+ ObjectName : metadata .objectName ,
944+ QueryValues : metadata .queryValues ,
955945 }
956946 for _ , m := range c .middlewares {
957947 if serializeM , ok := m .(SerializeMiddleware ); ok {
@@ -1236,150 +1226,4 @@ func (c *Client) GetCreds() (credentials.Value, error) {
12361226 return c .credsProvider .GetWithContext (c .CredContext ())
12371227}
12381228
1239- func resolveS3Operation (method string , metadata requestMetadata ) string {
1240- if metadata .s3Operation != "" {
1241- return metadata .s3Operation
1242- }
1243-
1244- hasQuery := func (key string ) bool {
1245- return metadata .queryValues .Get (key ) != "" || metadata .queryValues .Has (key )
1246- }
1247-
1248- isObject := metadata .objectName != ""
12491229
1250- switch method {
1251- case http .MethodGet :
1252- if isObject {
1253- if hasQuery ("tagging" ) {
1254- return "GetObjectTagging"
1255- }
1256- if hasQuery ("acl" ) {
1257- return "GetObjectAcl"
1258- }
1259- if hasQuery ("legal-hold" ) {
1260- return "GetObjectLegalHold"
1261- }
1262- if hasQuery ("retention" ) {
1263- return "GetObjectRetention"
1264- }
1265- return "GetObject"
1266- } else {
1267- if hasQuery ("lifecycle" ) {
1268- return "GetBucketLifecycle"
1269- }
1270- if hasQuery ("policy" ) {
1271- return "GetBucketPolicy"
1272- }
1273- if hasQuery ("notification" ) {
1274- return "GetBucketNotification"
1275- }
1276- if hasQuery ("cors" ) {
1277- return "GetBucketCors"
1278- }
1279- if hasQuery ("encryption" ) {
1280- return "GetBucketEncryption"
1281- }
1282- if hasQuery ("tagging" ) {
1283- return "GetBucketTagging"
1284- }
1285- if hasQuery ("versioning" ) {
1286- return "GetBucketVersioning"
1287- }
1288- if metadata .bucketName != "" {
1289- return "ListObjectsV2"
1290- }
1291- return "ListBuckets"
1292- }
1293-
1294- case http .MethodPut :
1295- if isObject {
1296- if hasQuery ("tagging" ) {
1297- return "PutObjectTagging"
1298- }
1299- if hasQuery ("acl" ) {
1300- return "PutObjectAcl"
1301- }
1302- if hasQuery ("legal-hold" ) {
1303- return "PutObjectLegalHold"
1304- }
1305- if hasQuery ("retention" ) {
1306- return "PutObjectRetention"
1307- }
1308- return "PutObject"
1309- } else {
1310- if hasQuery ("lifecycle" ) {
1311- return "PutBucketLifecycle"
1312- }
1313- if hasQuery ("policy" ) {
1314- return "PutBucketPolicy"
1315- }
1316- if hasQuery ("notification" ) {
1317- return "PutBucketNotification"
1318- }
1319- if hasQuery ("cors" ) {
1320- return "PutBucketCors"
1321- }
1322- if hasQuery ("encryption" ) {
1323- return "PutBucketEncryption"
1324- }
1325- if hasQuery ("tagging" ) {
1326- return "PutBucketTagging"
1327- }
1328- if hasQuery ("versioning" ) {
1329- return "PutBucketVersioning"
1330- }
1331- return "CreateBucket"
1332- }
1333-
1334- case http .MethodDelete :
1335- if isObject {
1336- if hasQuery ("tagging" ) {
1337- return "DeleteObjectTagging"
1338- }
1339- return "DeleteObject"
1340- } else {
1341- if hasQuery ("lifecycle" ) {
1342- return "DeleteBucketLifecycle"
1343- }
1344- if hasQuery ("policy" ) {
1345- return "DeleteBucketPolicy"
1346- }
1347- if hasQuery ("cors" ) {
1348- return "DeleteBucketCors"
1349- }
1350- if hasQuery ("encryption" ) {
1351- return "DeleteBucketEncryption"
1352- }
1353- if hasQuery ("tagging" ) {
1354- return "DeleteBucketTagging"
1355- }
1356- return "DeleteBucket"
1357- }
1358-
1359- case http .MethodHead :
1360- if isObject {
1361- return "HeadObject"
1362- }
1363- return "HeadBucket"
1364-
1365- case http .MethodPost :
1366- if isObject {
1367- if hasQuery ("uploads" ) {
1368- return "CreateMultipartUpload"
1369- }
1370- if hasQuery ("restore" ) {
1371- return "RestoreObject"
1372- }
1373- if hasQuery ("select" ) {
1374- return "SelectObjectContent"
1375- }
1376- return "PostObject"
1377- } else {
1378- if hasQuery ("delete" ) {
1379- return "DeleteObjects"
1380- }
1381- }
1382- }
1383-
1384- return method
1385- }
0 commit comments