smithy-rs/rust-runtime/inlineable
Zelda Hessler 1cecc3baa6
Fix request compression (#3820)
## Description
<!--- Describe your changes in detail -->
This PR includes several fixes for request compression:
- `aws_smithy_compression::body::compress::CompressedBody` will no
longer incorrectly return the inner body's `SizeHint`, returning
`SizeHint::default()` instead.
- Fixed a bug where compressed payloads would have an incorrect content
length, causing those requests to hang.
- Compress in-memory request payloads instead of the previous lazy
approach.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
Tests are included. Additionally, I ran a reproducer for a user issues
to ensure that their use case works:

```
#[tokio::test]
async fn use_case_reproducer() {
    tracing_subscriber::fmt::init();
    let shared_config = aws_config::from_env()
        .region(aws_sdk_cloudwatch::config::Region::new("us-west-2"))
        .load()
        .await;
    let service_config = aws_sdk_cloudwatch::config::Config::from(&shared_config)
        .to_builder()
        .request_min_compression_size_bytes(1)
        .build();
    let client = Client::from_conf(service_config);

    tracing::info!("sending metrics...");
    client
        .put_metric_data()
        .namespace("CloudWatchTestMetricsBrivinc")
        .metric_data(
            aws_sdk_cloudwatch::types::MetricDatum::builder()
                .metric_name(format!("MyMetricNameIsALittleLong"))
                .value(0.0)
                .build(),
        )
        .send()
        .await
        .unwrap();
}
``` 

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: ysaito1001 <awsaito@amazon.com>
2024-09-18 17:06:58 +00:00
..
src Fix request compression (#3820) 2024-09-18 17:06:58 +00:00
Cargo.toml Provide business metrics for RPC V2 CBOR, Gzip request compression, paginator, and waiter (#3793) 2024-08-20 21:20:27 +00:00
LICENSE docs.rs metadata & license linter & fixes (#904) 2021-12-01 12:26:47 +01:00
README.md Fix repo org move issues (#3166) 2023-11-10 18:51:04 +00:00
external-types.toml Check external types for runtime and SDK crates in CI (#1625) 2022-08-10 18:33:43 -07:00

README.md

aws-inlineable

This is not a "real" crate, but instead a collection of Rust files which can be automatically copied into generated SDKs. This exists to facilitate writing complex snippets of code that can be tested with normal testing machinery without needing to create and publish an entire additional crate.

This crate is part of the AWS SDK for Rust and the smithy-rs code generator. In most cases, it should not be used directly.