@@ -268,6 +268,7 @@ pub(crate) struct Request<'a> {
268
268
builder : RequestBuilder ,
269
269
payload_sha256 : Option < Vec < u8 > > ,
270
270
use_session_creds : bool ,
271
+ idempotent : bool ,
271
272
}
272
273
273
274
impl < ' a > Request < ' a > {
@@ -285,6 +286,11 @@ impl<'a> Request<'a> {
285
286
Self { builder, ..self }
286
287
}
287
288
289
+ pub fn set_idempotent ( mut self , idempotent : bool ) -> Self {
290
+ self . idempotent = idempotent;
291
+ self
292
+ }
293
+
288
294
pub async fn send ( self ) -> Result < Response , RequestError > {
289
295
let credential = match self . use_session_creds {
290
296
true => self . config . get_session_credential ( ) . await ?,
@@ -298,7 +304,7 @@ impl<'a> Request<'a> {
298
304
let path = self . path . as_ref ( ) ;
299
305
self . builder
300
306
. with_aws_sigv4 ( credential. authorizer ( ) , self . payload_sha256 . as_deref ( ) )
301
- . send_retry ( & self . config . retry_config )
307
+ . send_retry_with_idempotency ( & self . config . retry_config , self . idempotent )
302
308
. await
303
309
. context ( RetrySnafu { path } )
304
310
}
@@ -360,6 +366,7 @@ impl S3Client {
360
366
payload_sha256,
361
367
config : & self . config ,
362
368
use_session_creds : true ,
369
+ idempotent : false ,
363
370
}
364
371
}
365
372
@@ -462,7 +469,7 @@ impl S3Client {
462
469
. header ( CONTENT_TYPE , "application/xml" )
463
470
. body ( body)
464
471
. with_aws_sigv4 ( credential. authorizer ( ) , payload_sha256. as_deref ( ) )
465
- . send_retry ( & self . config . retry_config )
472
+ . send_retry_with_idempotency ( & self . config . retry_config , false )
466
473
. await
467
474
. context ( DeleteObjectsRequestSnafu { } ) ?
468
475
. bytes ( )
@@ -510,6 +517,7 @@ impl S3Client {
510
517
config : & self . config ,
511
518
payload_sha256 : None ,
512
519
use_session_creds : false ,
520
+ idempotent : false ,
513
521
}
514
522
}
515
523
@@ -522,7 +530,7 @@ impl S3Client {
522
530
. request ( Method :: POST , url)
523
531
. headers ( self . config . encryption_headers . clone ( ) . into ( ) )
524
532
. with_aws_sigv4 ( credential. authorizer ( ) , None )
525
- . send_retry ( & self . config . retry_config )
533
+ . send_retry_with_idempotency ( & self . config . retry_config , true )
526
534
. await
527
535
. context ( CreateMultipartRequestSnafu ) ?
528
536
. bytes ( )
@@ -547,6 +555,7 @@ impl S3Client {
547
555
let response = self
548
556
. put_request ( path, data, false )
549
557
. query ( & [ ( "partNumber" , & part) , ( "uploadId" , upload_id) ] )
558
+ . set_idempotent ( true )
550
559
. send ( )
551
560
. await ?;
552
561
@@ -582,7 +591,7 @@ impl S3Client {
582
591
. query ( & [ ( "uploadId" , upload_id) ] )
583
592
. body ( body)
584
593
. with_aws_sigv4 ( credential. authorizer ( ) , None )
585
- . send_retry ( & self . config . retry_config )
594
+ . send_retry_with_idempotency ( & self . config . retry_config , true )
586
595
. await
587
596
. context ( CompleteMultipartRequestSnafu ) ?;
588
597
0 commit comments