AWS SDK

AWS SDK

rev. f50aa8c7588f148ef5f1d01ff1bfa3ac2f1cbded (ignoring whitespace)

Files changed:

tmp-codegen-diff/aws-sdk/sdk/ecs/src/endpoint_lib/partition.rs

@@ -3,3 +62,63 @@
   23     23   
    partitions: Vec<PartitionMetadata>,
   24     24   
}
   25     25   
   26     26   
impl PartitionResolver {
   27     27   
    pub(crate) fn from_partitions(partitions: Vec<PartitionMetadata>) -> Self {
   28     28   
        Self { partitions }
   29     29   
    }
   30     30   
}
   31     31   
   32     32   
/// Partition result returned from partition resolver
          33  +
#[derive(Debug, Default, Clone)]
   33     34   
pub(crate) struct Partition<'a> {
   34     35   
    name: &'a str,
   35     36   
    dns_suffix: &'a str,
   36     37   
    dual_stack_dns_suffix: &'a str,
   37     38   
    supports_fips: bool,
   38     39   
    supports_dual_stack: bool,
   39     40   
    implicit_global_region: &'a str,
   40     41   
}
   41     42   
   42     43   
#[allow(unused)]

tmp-codegen-diff/aws-sdk/sdk/glacier/src/endpoint_lib/diagnostic.rs

@@ -7,7 +45,46 @@
   27     27   
    pub(crate) fn capture<T, E: Into<Box<dyn Error + Send + Sync>>>(&mut self, err: Result<T, E>) -> Option<T> {
   28     28   
        match err {
   29     29   
            Ok(res) => Some(res),
   30     30   
            Err(e) => {
   31     31   
                self.report_error(e);
   32     32   
                None
   33     33   
            }
   34     34   
        }
   35     35   
    }
   36     36   
          37  +
    #[allow(dead_code)]
   37     38   
    pub(crate) fn take_last_error(&mut self) -> Option<Box<dyn Error + Send + Sync>> {
   38     39   
        self.last_error.take()
   39     40   
    }
   40     41   
   41     42   
    /// Create a new diagnostic collector
   42     43   
    pub(crate) fn new() -> Self {
   43     44   
        Self { last_error: None }
   44     45   
    }
   45     46   
}

tmp-codegen-diff/aws-sdk/sdk/glacier/src/endpoint_lib/partition.rs

@@ -3,3 +62,63 @@
   23     23   
    partitions: Vec<PartitionMetadata>,
   24     24   
}
   25     25   
   26     26   
impl PartitionResolver {
   27     27   
    pub(crate) fn from_partitions(partitions: Vec<PartitionMetadata>) -> Self {
   28     28   
        Self { partitions }
   29     29   
    }
   30     30   
}
   31     31   
   32     32   
/// Partition result returned from partition resolver
          33  +
#[derive(Debug, Default, Clone)]
   33     34   
pub(crate) struct Partition<'a> {
   34     35   
    name: &'a str,
   35     36   
    dns_suffix: &'a str,
   36     37   
    dual_stack_dns_suffix: &'a str,
   37     38   
    supports_fips: bool,
   38     39   
    supports_dual_stack: bool,
   39     40   
    implicit_global_region: &'a str,
   40     41   
}
   41     42   
   42     43   
#[allow(unused)]

tmp-codegen-diff/aws-sdk/sdk/iam/src/endpoint_lib/diagnostic.rs

@@ -7,7 +45,46 @@
   27     27   
    pub(crate) fn capture<T, E: Into<Box<dyn Error + Send + Sync>>>(&mut self, err: Result<T, E>) -> Option<T> {
   28     28   
        match err {
   29     29   
            Ok(res) => Some(res),
   30     30   
            Err(e) => {
   31     31   
                self.report_error(e);
   32     32   
                None
   33     33   
            }
   34     34   
        }
   35     35   
    }
   36     36   
          37  +
    #[allow(dead_code)]
   37     38   
    pub(crate) fn take_last_error(&mut self) -> Option<Box<dyn Error + Send + Sync>> {
   38     39   
        self.last_error.take()
   39     40   
    }
   40     41   
   41     42   
    /// Create a new diagnostic collector
   42     43   
    pub(crate) fn new() -> Self {
   43     44   
        Self { last_error: None }
   44     45   
    }
   45     46   
}

tmp-codegen-diff/aws-sdk/sdk/iam/src/endpoint_lib/partition.rs

@@ -3,3 +62,63 @@
   23     23   
    partitions: Vec<PartitionMetadata>,
   24     24   
}
   25     25   
   26     26   
impl PartitionResolver {
   27     27   
    pub(crate) fn from_partitions(partitions: Vec<PartitionMetadata>) -> Self {
   28     28   
        Self { partitions }
   29     29   
    }
   30     30   
}
   31     31   
   32     32   
/// Partition result returned from partition resolver
          33  +
#[derive(Debug, Default, Clone)]
   33     34   
pub(crate) struct Partition<'a> {
   34     35   
    name: &'a str,
   35     36   
    dns_suffix: &'a str,
   36     37   
    dual_stack_dns_suffix: &'a str,
   37     38   
    supports_fips: bool,
   38     39   
    supports_dual_stack: bool,
   39     40   
    implicit_global_region: &'a str,
   40     41   
}
   41     42   
   42     43   
#[allow(unused)]

tmp-codegen-diff/aws-sdk/sdk/kms/src/endpoint_lib/diagnostic.rs

@@ -7,7 +45,46 @@
   27     27   
    pub(crate) fn capture<T, E: Into<Box<dyn Error + Send + Sync>>>(&mut self, err: Result<T, E>) -> Option<T> {
   28     28   
        match err {
   29     29   
            Ok(res) => Some(res),
   30     30   
            Err(e) => {
   31     31   
                self.report_error(e);
   32     32   
                None
   33     33   
            }
   34     34   
        }
   35     35   
    }
   36     36   
          37  +
    #[allow(dead_code)]
   37     38   
    pub(crate) fn take_last_error(&mut self) -> Option<Box<dyn Error + Send + Sync>> {
   38     39   
        self.last_error.take()
   39     40   
    }
   40     41   
   41     42   
    /// Create a new diagnostic collector
   42     43   
    pub(crate) fn new() -> Self {
   43     44   
        Self { last_error: None }
   44     45   
    }
   45     46   
}

tmp-codegen-diff/aws-sdk/sdk/kms/src/endpoint_lib/partition.rs

@@ -3,3 +62,63 @@
   23     23   
    partitions: Vec<PartitionMetadata>,
   24     24   
}
   25     25   
   26     26   
impl PartitionResolver {
   27     27   
    pub(crate) fn from_partitions(partitions: Vec<PartitionMetadata>) -> Self {
   28     28   
        Self { partitions }
   29     29   
    }
   30     30   
}
   31     31   
   32     32   
/// Partition result returned from partition resolver
          33  +
#[derive(Debug, Default, Clone)]
   33     34   
pub(crate) struct Partition<'a> {
   34     35   
    name: &'a str,
   35     36   
    dns_suffix: &'a str,
   36     37   
    dual_stack_dns_suffix: &'a str,
   37     38   
    supports_fips: bool,
   38     39   
    supports_dual_stack: bool,
   39     40   
    implicit_global_region: &'a str,
   40     41   
}
   41     42   
   42     43   
#[allow(unused)]

tmp-codegen-diff/aws-sdk/sdk/lambda/src/endpoint_lib/diagnostic.rs

@@ -7,7 +45,46 @@
   27     27   
    pub(crate) fn capture<T, E: Into<Box<dyn Error + Send + Sync>>>(&mut self, err: Result<T, E>) -> Option<T> {
   28     28   
        match err {
   29     29   
            Ok(res) => Some(res),
   30     30   
            Err(e) => {
   31     31   
                self.report_error(e);
   32     32   
                None
   33     33   
            }
   34     34   
        }
   35     35   
    }
   36     36   
          37  +
    #[allow(dead_code)]
   37     38   
    pub(crate) fn take_last_error(&mut self) -> Option<Box<dyn Error + Send + Sync>> {
   38     39   
        self.last_error.take()
   39     40   
    }
   40     41   
   41     42   
    /// Create a new diagnostic collector
   42     43   
    pub(crate) fn new() -> Self {
   43     44   
        Self { last_error: None }
   44     45   
    }
   45     46   
}

tmp-codegen-diff/aws-sdk/sdk/lambda/src/endpoint_lib/partition.rs

@@ -3,3 +62,63 @@
   23     23   
    partitions: Vec<PartitionMetadata>,
   24     24   
}
   25     25   
   26     26   
impl PartitionResolver {
   27     27   
    pub(crate) fn from_partitions(partitions: Vec<PartitionMetadata>) -> Self {
   28     28   
        Self { partitions }
   29     29   
    }
   30     30   
}
   31     31   
   32     32   
/// Partition result returned from partition resolver
          33  +
#[derive(Debug, Default, Clone)]
   33     34   
pub(crate) struct Partition<'a> {
   34     35   
    name: &'a str,
   35     36   
    dns_suffix: &'a str,
   36     37   
    dual_stack_dns_suffix: &'a str,
   37     38   
    supports_fips: bool,
   38     39   
    supports_dual_stack: bool,
   39     40   
    implicit_global_region: &'a str,
   40     41   
}
   41     42   
   42     43   
#[allow(unused)]

tmp-codegen-diff/aws-sdk/sdk/polly/src/endpoint_lib/diagnostic.rs

@@ -7,7 +45,46 @@
   27     27   
    pub(crate) fn capture<T, E: Into<Box<dyn Error + Send + Sync>>>(&mut self, err: Result<T, E>) -> Option<T> {
   28     28   
        match err {
   29     29   
            Ok(res) => Some(res),
   30     30   
            Err(e) => {
   31     31   
                self.report_error(e);
   32     32   
                None
   33     33   
            }
   34     34   
        }
   35     35   
    }
   36     36   
          37  +
    #[allow(dead_code)]
   37     38   
    pub(crate) fn take_last_error(&mut self) -> Option<Box<dyn Error + Send + Sync>> {
   38     39   
        self.last_error.take()
   39     40   
    }
   40     41   
   41     42   
    /// Create a new diagnostic collector
   42     43   
    pub(crate) fn new() -> Self {
   43     44   
        Self { last_error: None }
   44     45   
    }
   45     46   
}

tmp-codegen-diff/aws-sdk/sdk/polly/src/endpoint_lib/partition.rs

@@ -3,3 +62,63 @@
   23     23   
    partitions: Vec<PartitionMetadata>,
   24     24   
}
   25     25   
   26     26   
impl PartitionResolver {
   27     27   
    pub(crate) fn from_partitions(partitions: Vec<PartitionMetadata>) -> Self {
   28     28   
        Self { partitions }
   29     29   
    }
   30     30   
}
   31     31   
   32     32   
/// Partition result returned from partition resolver
          33  +
#[derive(Debug, Default, Clone)]
   33     34   
pub(crate) struct Partition<'a> {
   34     35   
    name: &'a str,
   35     36   
    dns_suffix: &'a str,
   36     37   
    dual_stack_dns_suffix: &'a str,
   37     38   
    supports_fips: bool,
   38     39   
    supports_dual_stack: bool,
   39     40   
    implicit_global_region: &'a str,
   40     41   
}
   41     42   
   42     43   
#[allow(unused)]

tmp-codegen-diff/aws-sdk/sdk/route53/src/endpoint_lib/diagnostic.rs

@@ -7,7 +45,46 @@
   27     27   
    pub(crate) fn capture<T, E: Into<Box<dyn Error + Send + Sync>>>(&mut self, err: Result<T, E>) -> Option<T> {
   28     28   
        match err {
   29     29   
            Ok(res) => Some(res),
   30     30   
            Err(e) => {
   31     31   
                self.report_error(e);
   32     32   
                None
   33     33   
            }
   34     34   
        }
   35     35   
    }
   36     36   
          37  +
    #[allow(dead_code)]
   37     38   
    pub(crate) fn take_last_error(&mut self) -> Option<Box<dyn Error + Send + Sync>> {
   38     39   
        self.last_error.take()
   39     40   
    }
   40     41   
   41     42   
    /// Create a new diagnostic collector
   42     43   
    pub(crate) fn new() -> Self {
   43     44   
        Self { last_error: None }
   44     45   
    }
   45     46   
}

tmp-codegen-diff/aws-sdk/sdk/route53/src/endpoint_lib/partition.rs

@@ -3,3 +62,63 @@
   23     23   
    partitions: Vec<PartitionMetadata>,
   24     24   
}
   25     25   
   26     26   
impl PartitionResolver {
   27     27   
    pub(crate) fn from_partitions(partitions: Vec<PartitionMetadata>) -> Self {
   28     28   
        Self { partitions }
   29     29   
    }
   30     30   
}
   31     31   
   32     32   
/// Partition result returned from partition resolver
          33  +
#[derive(Debug, Default, Clone)]
   33     34   
pub(crate) struct Partition<'a> {
   34     35   
    name: &'a str,
   35     36   
    dns_suffix: &'a str,
   36     37   
    dual_stack_dns_suffix: &'a str,
   37     38   
    supports_fips: bool,
   38     39   
    supports_dual_stack: bool,
   39     40   
    implicit_global_region: &'a str,
   40     41   
}
   41     42   
   42     43   
#[allow(unused)]

tmp-codegen-diff/aws-sdk/sdk/s3/Cargo.toml

@@ -1,1 +75,70 @@
   14     14   
protocol = "aws.protocols#restXml"
   15     15   
[package.metadata.docs.rs]
   16     16   
all-features = true
   17     17   
targets = ["x86_64-unknown-linux-gnu"]
   18     18   
[dependencies.aws-credential-types]
   19     19   
path = "../aws-credential-types"
   20     20   
version = "1.2.11"
   21     21   
   22     22   
[dependencies.aws-runtime]
   23     23   
path = "../aws-runtime"
   24         -
features = ["event-stream", "http-02x"]
          24  +
features = ["http-02x"]
   25     25   
version = "1.5.17"
   26     26   
   27     27   
[dependencies.aws-sigv4]
   28     28   
path = "../aws-sigv4"
   29     29   
version = "1.3.7"
   30     30   
   31     31   
[dependencies.aws-smithy-async]
   32     32   
path = "../aws-smithy-async"
   33     33   
version = "1.2.7"
   34     34   
   35     35   
[dependencies.aws-smithy-checksums]
   36     36   
path = "../aws-smithy-checksums"
   37     37   
version = "0.63.12"
   38     38   
   39         -
[dependencies.aws-smithy-eventstream]
   40         -
path = "../aws-smithy-eventstream"
   41         -
version = "0.60.14"
   42         -
   43     39   
[dependencies.aws-smithy-http]
   44     40   
path = "../aws-smithy-http"
   45         -
features = ["event-stream"]
   46     41   
version = "0.62.6"
   47     42   
   48     43   
[dependencies.aws-smithy-json]
   49     44   
path = "../aws-smithy-json"
   50     45   
version = "0.61.8"
   51     46   
   52     47   
[dependencies.aws-smithy-runtime]
   53     48   
path = "../aws-smithy-runtime"
   54     49   
features = ["client"]
   55     50   
version = "1.9.5"
@@ -111,106 +175,165 @@
  131    126   
[dev-dependencies.aws-runtime]
  132    127   
path = "../aws-runtime"
  133    128   
features = ["test-util"]
  134    129   
version = "1.5.17"
  135    130   
  136    131   
[dev-dependencies.aws-smithy-async]
  137    132   
path = "../aws-smithy-async"
  138    133   
features = ["test-util"]
  139    134   
version = "1.2.7"
  140    135   
  141         -
[dev-dependencies.aws-smithy-eventstream]
  142         -
path = "../aws-smithy-eventstream"
  143         -
features = ["test-util"]
  144         -
version = "0.60.14"
  145         -
  146    136   
[dev-dependencies.aws-smithy-http-client]
  147    137   
path = "../aws-smithy-http-client"
  148    138   
features = ["test-util", "wire-mock", "rustls-ring"]
  149    139   
version = "1.1.5"
  150    140   
  151    141   
[dev-dependencies.aws-smithy-mocks]
  152    142   
path = "../aws-smithy-mocks"
  153    143   
version = "0.2.2"
  154    144   
  155    145   
[dev-dependencies.aws-smithy-protocol-test]
@@ -198,188 +234,224 @@
  218    208   
[dev-dependencies.tracing-test]
  219    209   
version = "0.2.5"
  220    210   
features = ["no-env-filter"]
  221    211   
  222    212   
[features]
  223    213   
sigv4a = ["aws-runtime/sigv4a"]
  224    214   
http-1x = ["dep:http-body-1x", "aws-smithy-runtime-api/http-1x"]
  225    215   
behavior-version-latest = []
  226    216   
rustls = ["aws-smithy-runtime/tls-rustls"]
  227    217   
default-https-client = ["aws-smithy-runtime/default-https-client"]
  228         -
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
  229    218   
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
         219  +
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
  230    220   
gated-tests = []
  231    221   
default = ["sigv4a", "rustls", "default-https-client", "rt-tokio"]
  232    222   
  233    223   
[hints]
  234    224   
mostly-unused = true

tmp-codegen-diff/aws-sdk/sdk/s3/src/aws_chunked.rs

@@ -1,0 +292,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
/*
    3         -
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
    4         -
 * SPDX-License-Identifier: Apache-2.0
    5         -
 */
    6         -
    7         -
#![allow(dead_code)]
    8         -
    9         -
use std::fmt;
   10         -
   11         -
use aws_runtime::{
   12         -
    auth::PayloadSigningOverride,
   13         -
    content_encoding::{header_value::AWS_CHUNKED, AwsChunkedBody, AwsChunkedBodyOptions},
   14         -
};
   15         -
use aws_smithy_runtime_api::{
   16         -
    box_error::BoxError,
   17         -
    client::{
   18         -
        interceptors::{context::BeforeTransmitInterceptorContextMut, Intercept},
   19         -
        runtime_components::RuntimeComponents,
   20         -
    },
   21         -
    http::Request,
   22         -
};
   23         -
use aws_smithy_types::{body::SdkBody, config_bag::ConfigBag, error::operation::BuildError};
   24         -
use http::{header, HeaderValue};
   25         -
use http_body::Body;
   26         -
   27         -
const X_AMZ_DECODED_CONTENT_LENGTH: &str = "x-amz-decoded-content-length";
   28         -
   29         -
/// Errors related to constructing aws-chunked encoded HTTP requests.
   30         -
#[derive(Debug)]
   31         -
enum Error {
   32         -
    UnsizedRequestBody,
   33         -
}
   34         -
   35         -
impl fmt::Display for Error {
   36         -
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
   37         -
        match self {
   38         -
            Self::UnsizedRequestBody => write!(f, "Only request bodies with a known size can be aws-chunked encoded."),
   39         -
        }
   40         -
    }
   41         -
}
   42         -
   43         -
impl std::error::Error for Error {}
   44         -
   45         -
#[derive(Debug)]
   46         -
pub(crate) struct AwsChunkedContentEncodingInterceptor;
   47         -
   48         -
impl Intercept for AwsChunkedContentEncodingInterceptor {
   49         -
    fn name(&self) -> &'static str {
   50         -
        "AwsChunkedContentEncodingInterceptor"
   51         -
    }
   52         -
   53         -
    fn modify_before_signing(
   54         -
        &self,
   55         -
        context: &mut BeforeTransmitInterceptorContextMut<'_>,
   56         -
        _runtime_components: &RuntimeComponents,
   57         -
        cfg: &mut ConfigBag,
   58         -
    ) -> Result<(), BoxError> {
   59         -
        if must_not_use_chunked_encoding(context.request(), cfg) {
   60         -
            tracing::debug!("short-circuiting modify_before_signing because chunked encoding must not be used");
   61         -
            return Ok(());
   62         -
        }
   63         -
   64         -
        let original_body_size = if let Some(size) = context
   65         -
            .request()
   66         -
            .headers()
   67         -
            .get(header::CONTENT_LENGTH)
   68         -
            .and_then(|s| s.parse::<u64>().ok())
   69         -
            .or_else(|| context.request().body().size_hint().exact())
   70         -
        {
   71         -
            size
   72         -
        } else {
   73         -
            return Err(BuildError::other(Error::UnsizedRequestBody))?;
   74         -
        };
   75         -
   76         -
        let chunked_body_options = if let Some(chunked_body_options) = cfg.get_mut_from_interceptor_state::<AwsChunkedBodyOptions>() {
   77         -
            let chunked_body_options = std::mem::take(chunked_body_options);
   78         -
            chunked_body_options.with_stream_length(original_body_size)
   79         -
        } else {
   80         -
            AwsChunkedBodyOptions::default().with_stream_length(original_body_size)
   81         -
        };
   82         -
   83         -
        let request = context.request_mut();
   84         -
        // For for aws-chunked encoding, `x-amz-decoded-content-length` must be set to the original body size.
   85         -
        request.headers_mut().insert(
   86         -
            header::HeaderName::from_static(X_AMZ_DECODED_CONTENT_LENGTH),
   87         -
            HeaderValue::from(original_body_size),
   88         -
        );
   89         -
        // Other than `x-amz-decoded-content-length`, either `content-length` or `transfer-encoding`
   90         -
        // must be set, but not both. For uses cases we support, we know the original body size and
   91         -
        // can calculate the encoded size, so we set `content-length`.
   92         -
        request
   93         -
            .headers_mut()
   94         -
            .insert(header::CONTENT_LENGTH, HeaderValue::from(chunked_body_options.encoded_length()));
   95         -
        // Setting `content-length` above means we must unset `transfer-encoding`.
   96         -
        request.headers_mut().remove(header::TRANSFER_ENCODING);
   97         -
        request.headers_mut().append(
   98         -
            header::CONTENT_ENCODING,
   99         -
            HeaderValue::from_str(AWS_CHUNKED)
  100         -
                .map_err(BuildError::other)
  101         -
                .expect("\"aws-chunked\" will always be a valid HeaderValue"),
  102         -
        );
  103         -
  104         -
        cfg.interceptor_state().store_put(chunked_body_options);
  105         -
        cfg.interceptor_state().store_put(PayloadSigningOverride::StreamingUnsignedPayloadTrailer);
  106         -
  107         -
        Ok(())
  108         -
    }
  109         -
  110         -
    fn modify_before_transmit(
  111         -
        &self,
  112         -
        ctx: &mut BeforeTransmitInterceptorContextMut<'_>,
  113         -
        _runtime_components: &RuntimeComponents,
  114         -
        cfg: &mut ConfigBag,
  115         -
    ) -> Result<(), BoxError> {
  116         -
        if must_not_use_chunked_encoding(ctx.request(), cfg) {
  117         -
            tracing::debug!("short-circuiting modify_before_transmit because chunked encoding must not be used");
  118         -
            return Ok(());
  119         -
        }
  120         -
  121         -
        let request = ctx.request_mut();
  122         -
  123         -
        let mut body = {
  124         -
            let body = std::mem::replace(request.body_mut(), SdkBody::taken());
  125         -
            let opt = cfg
  126         -
                .get_mut_from_interceptor_state::<AwsChunkedBodyOptions>()
  127         -
                .ok_or_else(|| BuildError::other("AwsChunkedBodyOptions missing from config bag"))?;
  128         -
            let aws_chunked_body_options = std::mem::take(opt);
  129         -
            body.map(move |body| {
  130         -
                let body = AwsChunkedBody::new(body, aws_chunked_body_options.clone());
  131         -
                SdkBody::from_body_0_4(body)
  132         -
            })
  133         -
        };
  134         -
  135         -
        std::mem::swap(request.body_mut(), &mut body);
  136         -
  137         -
        Ok(())
  138         -
    }
  139         -
}
  140         -
  141         -
// Determine if chunked encoding must not be used; returns true when any of the following is true:
  142         -
// - If the body is in-memory
  143         -
// - If chunked encoding is disabled via `AwsChunkedBodyOptions`
  144         -
fn must_not_use_chunked_encoding(request: &Request, cfg: &ConfigBag) -> bool {
  145         -
    match (request.body().bytes(), cfg.load::<AwsChunkedBodyOptions>()) {
  146         -
        (Some(_), _) => true,
  147         -
        (_, Some(options)) if options.disabled() => true,
  148         -
        _ => false,
  149         -
    }
  150         -
}
  151         -
  152         -
#[cfg(test)]
  153         -
mod tests {
  154         -
    use super::*;
  155         -
    use aws_smithy_runtime_api::client::interceptors::context::{BeforeTransmitInterceptorContextMut, Input, InterceptorContext};
  156         -
    use aws_smithy_runtime_api::client::orchestrator::HttpRequest;
  157         -
    use aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
  158         -
    use aws_smithy_types::byte_stream::ByteStream;
  159         -
    use bytes::BytesMut;
  160         -
    use http_body::Body;
  161         -
    use tempfile::NamedTempFile;
  162         -
  163         -
    #[tokio::test]
  164         -
    async fn test_aws_chunked_body_is_retryable() {
  165         -
        use std::io::Write;
  166         -
        let mut file = NamedTempFile::new().unwrap();
  167         -
  168         -
        for i in 0..10000 {
  169         -
            let line = format!("This is a large file created for testing purposes {}", i);
  170         -
            file.as_file_mut().write_all(line.as_bytes()).unwrap();
  171         -
        }
  172         -
  173         -
        let stream_length = file.as_file().metadata().unwrap().len();
  174         -
        let request = HttpRequest::new(ByteStream::read_from().path(&file).buffer_size(1024).build().await.unwrap().into_inner());
  175         -
  176         -
        // ensure original SdkBody is retryable
  177         -
        assert!(request.body().try_clone().is_some());
  178         -
  179         -
        let interceptor = AwsChunkedContentEncodingInterceptor;
  180         -
        let mut cfg = ConfigBag::base();
  181         -
        cfg.interceptor_state()
  182         -
            .store_put(AwsChunkedBodyOptions::default().with_stream_length(stream_length));
  183         -
        let runtime_components = RuntimeComponentsBuilder::for_tests().build().unwrap();
  184         -
        let mut ctx = InterceptorContext::new(Input::doesnt_matter());
  185         -
        ctx.enter_serialization_phase();
  186         -
        let _ = ctx.take_input();
  187         -
        ctx.set_request(request);
  188         -
        ctx.enter_before_transmit_phase();
  189         -
        let mut ctx: BeforeTransmitInterceptorContextMut<'_> = (&mut ctx).into();
  190         -
        interceptor.modify_before_transmit(&mut ctx, &runtime_components, &mut cfg).unwrap();
  191         -
  192         -
        // ensure wrapped SdkBody is retryable
  193         -
        let mut body = ctx.request().body().try_clone().expect("body is retryable");
  194         -
  195         -
        let mut body_data = BytesMut::new();
  196         -
        while let Some(data) = body.data().await {
  197         -
            body_data.extend_from_slice(&data.unwrap())
  198         -
        }
  199         -
        let body_str = std::str::from_utf8(&body_data).unwrap();
  200         -
  201         -
        let expected = "This is a large file created for testing purposes 9999\r\n0\r\n\r\n";
  202         -
        assert!(body_str.ends_with(expected), "expected '{body_str}' to end with '{expected}'");
  203         -
    }
  204         -
  205         -
    #[tokio::test]
  206         -
    async fn test_short_circuit_modify_before_signing() {
  207         -
        let mut ctx = InterceptorContext::new(Input::doesnt_matter());
  208         -
        ctx.enter_serialization_phase();
  209         -
        let _ = ctx.take_input();
  210         -
        let request = HttpRequest::new(SdkBody::from("in-memory body, must not use chunked encoding"));
  211         -
        ctx.set_request(request);
  212         -
        ctx.enter_before_transmit_phase();
  213         -
        let mut ctx: BeforeTransmitInterceptorContextMut<'_> = (&mut ctx).into();
  214         -
  215         -
        let runtime_components = RuntimeComponentsBuilder::for_tests().build().unwrap();
  216         -
  217         -
        let mut cfg = ConfigBag::base();
  218         -
        cfg.interceptor_state().store_put(AwsChunkedBodyOptions::default());
  219         -
  220         -
        let interceptor = AwsChunkedContentEncodingInterceptor;
  221         -
        interceptor.modify_before_signing(&mut ctx, &runtime_components, &mut cfg).unwrap();
  222         -
  223         -
        let request = ctx.request();
  224         -
        assert!(request.headers().get(header::CONTENT_ENCODING).is_none());
  225         -
        assert!(request
  226         -
            .headers()
  227         -
            .get(header::HeaderName::from_static(X_AMZ_DECODED_CONTENT_LENGTH))
  228         -
            .is_none());
  229         -
    }
  230         -
  231         -
    #[tokio::test]
  232         -
    async fn test_short_circuit_modify_before_transmit() {
  233         -
        let mut ctx = InterceptorContext::new(Input::doesnt_matter());
  234         -
        ctx.enter_serialization_phase();
  235         -
        let _ = ctx.take_input();
  236         -
        let request = HttpRequest::new(SdkBody::from("in-memory body, must not use chunked encoding"));
  237         -
        ctx.set_request(request);
  238         -
        ctx.enter_before_transmit_phase();
  239         -
        let mut ctx: BeforeTransmitInterceptorContextMut<'_> = (&mut ctx).into();
  240         -
  241         -
        let runtime_components = RuntimeComponentsBuilder::for_tests().build().unwrap();
  242         -
  243         -
        let mut cfg = ConfigBag::base();
  244         -
        // Don't need to set the stream length properly because we expect the body won't be wrapped by `AwsChunkedBody`.
  245         -
        cfg.interceptor_state().store_put(AwsChunkedBodyOptions::default());
  246         -
  247         -
        let interceptor = AwsChunkedContentEncodingInterceptor;
  248         -
        interceptor.modify_before_transmit(&mut ctx, &runtime_components, &mut cfg).unwrap();
  249         -
  250         -
        let mut body = ctx.request().body().try_clone().expect("body is retryable");
  251         -
  252         -
        let mut body_data = BytesMut::new();
  253         -
        while let Some(data) = body.data().await {
  254         -
            body_data.extend_from_slice(&data.unwrap())
  255         -
        }
  256         -
        let body_str = std::str::from_utf8(&body_data).unwrap();
  257         -
        // Also implies that `assert!(!body_str.ends_with("0\r\n\r\n"));`, i.e., shouldn't see chunked encoding epilogue.
  258         -
        assert_eq!("in-memory body, must not use chunked encoding", body_str);
  259         -
    }
  260         -
  261         -
    #[test]
  262         -
    fn test_must_not_use_chunked_encoding_with_in_memory_body() {
  263         -
        let request = HttpRequest::new(SdkBody::from("test body"));
  264         -
        let cfg = ConfigBag::base();
  265         -
  266         -
        assert!(must_not_use_chunked_encoding(&request, &cfg));
  267         -
    }
  268         -
  269         -
    async fn streaming_body(path: impl AsRef<std::path::Path>) -> SdkBody {
  270         -
        let file = path.as_ref();
  271         -
        ByteStream::read_from().path(&file).build().await.unwrap().into_inner()
  272         -
    }
  273         -
  274         -
    #[tokio::test]
  275         -
    async fn test_must_not_use_chunked_encoding_with_disabled_option() {
  276         -
        let file = NamedTempFile::new().unwrap();
  277         -
        let request = HttpRequest::new(streaming_body(&file).await);
  278         -
        let mut cfg = ConfigBag::base();
  279         -
        cfg.interceptor_state().store_put(AwsChunkedBodyOptions::disable_chunked_encoding());
  280         -
  281         -
        assert!(must_not_use_chunked_encoding(&request, &cfg));
  282         -
    }
  283         -
  284         -
    #[tokio::test]
  285         -
    async fn test_chunked_encoding_is_used() {
  286         -
        let file = NamedTempFile::new().unwrap();
  287         -
        let request = HttpRequest::new(streaming_body(&file).await);
  288         -
        let cfg = ConfigBag::base();
  289         -
  290         -
        assert!(!must_not_use_chunked_encoding(&request, &cfg));
  291         -
    }
  292         -
}

tmp-codegen-diff/aws-sdk/sdk/s3/src/client.rs

@@ -161,161 +315,309 @@
  181    181   
}
  182    182   
  183    183   
mod abort_multipart_upload;
  184    184   
  185    185   
mod complete_multipart_upload;
  186    186   
  187    187   
mod copy_object;
  188    188   
  189    189   
mod create_bucket;
  190    190   
  191         -
mod create_bucket_metadata_configuration;
  192         -
  193    191   
mod create_bucket_metadata_table_configuration;
  194    192   
  195    193   
mod create_multipart_upload;
  196    194   
  197    195   
mod create_session;
  198    196   
  199    197   
/// Operation customization and supporting types.
  200    198   
///
  201    199   
/// The underlying HTTP requests made during an operation can be customized
  202    200   
/// by calling the `customize()` method on the builder returned from a client
  203    201   
/// operation call. For example, this can be used to add an additional HTTP header:
  204    202   
///
  205    203   
/// ```ignore
  206    204   
/// # async fn wrapper() -> ::std::result::Result<(), aws_sdk_s3::Error> {
  207    205   
/// # let client: aws_sdk_s3::Client = unimplemented!();
  208    206   
/// use ::http::header::{HeaderName, HeaderValue};
  209    207   
///
  210    208   
/// let result = client.abort_multipart_upload()
  211    209   
///     .customize()
  212    210   
///     .mutate_request(|req| {
  213    211   
///         // Add `x-example-header` with value
  214    212   
///         req.headers_mut()
  215    213   
///             .insert(
  216    214   
///                 HeaderName::from_static("x-example-header"),
  217    215   
///                 HeaderValue::from_static("1"),
  218    216   
///             );
  219    217   
///     })
  220    218   
///     .send()
  221    219   
///     .await;
  222    220   
/// # }
  223    221   
/// ```
  224    222   
pub mod customize;
  225    223   
  226    224   
mod delete_bucket;
  227    225   
  228    226   
mod delete_bucket_analytics_configuration;
  229    227   
  230    228   
mod delete_bucket_cors;
  231    229   
  232    230   
mod delete_bucket_encryption;
  233    231   
  234    232   
mod delete_bucket_intelligent_tiering_configuration;
  235    233   
  236    234   
mod delete_bucket_inventory_configuration;
  237    235   
  238    236   
mod delete_bucket_lifecycle;
  239    237   
  240         -
mod delete_bucket_metadata_configuration;
  241         -
  242    238   
mod delete_bucket_metadata_table_configuration;
  243    239   
  244    240   
mod delete_bucket_metrics_configuration;
  245    241   
  246    242   
mod delete_bucket_ownership_controls;
  247    243   
  248    244   
mod delete_bucket_policy;
  249    245   
  250    246   
mod delete_bucket_replication;
  251    247   
  252    248   
mod delete_bucket_tagging;
  253    249   
  254    250   
mod delete_bucket_website;
  255    251   
  256    252   
mod delete_object;
  257    253   
  258    254   
mod delete_object_tagging;
  259    255   
  260    256   
mod delete_objects;
  261    257   
  262    258   
mod delete_public_access_block;
  263    259   
  264    260   
mod get_bucket_accelerate_configuration;
  265    261   
  266    262   
mod get_bucket_acl;
  267    263   
  268    264   
mod get_bucket_analytics_configuration;
  269    265   
  270    266   
mod get_bucket_cors;
  271    267   
  272    268   
mod get_bucket_encryption;
  273    269   
  274    270   
mod get_bucket_intelligent_tiering_configuration;
  275    271   
  276    272   
mod get_bucket_inventory_configuration;
  277    273   
  278    274   
mod get_bucket_lifecycle_configuration;
  279    275   
  280    276   
mod get_bucket_location;
  281    277   
  282    278   
mod get_bucket_logging;
  283    279   
  284         -
mod get_bucket_metadata_configuration;
  285         -
  286    280   
mod get_bucket_metadata_table_configuration;
  287    281   
  288    282   
mod get_bucket_metrics_configuration;
  289    283   
  290    284   
mod get_bucket_notification_configuration;
  291    285   
  292    286   
mod get_bucket_ownership_controls;
  293    287   
  294    288   
mod get_bucket_policy;
  295    289   
@@ -372,366 +416,402 @@
  392    386   
mod put_object_legal_hold;
  393    387   
  394    388   
mod put_object_lock_configuration;
  395    389   
  396    390   
mod put_object_retention;
  397    391   
  398    392   
mod put_object_tagging;
  399    393   
  400    394   
mod put_public_access_block;
  401    395   
  402         -
mod rename_object;
  403         -
  404    396   
mod restore_object;
  405    397   
  406         -
mod select_object_content;
  407         -
  408         -
mod update_bucket_metadata_inventory_table_configuration;
  409         -
  410         -
mod update_bucket_metadata_journal_table_configuration;
  411         -
  412    398   
mod upload_part;
  413    399   
  414    400   
mod upload_part_copy;
  415    401   
  416    402   
mod write_get_object_response;