Skip to content

Commit 9d6b6a1

Browse files
landonxjamesysaito1001rcohaws-sdk-rust-civcjana
authored
Merge feature/http 1.x to main (#4484)
## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here --> All Smithy-rs crates, for both servers and clients, now use the `1.x` version of the `http` crate for all internal processing. Utility methods are still provided for users to convert between SDK types and types from both the `0.x` and `1.x` versions of the `http` crate. ## Description <!--- Describe your changes in detail --> There are too many changes to describe in detail, but this work has been split over many other PRs to the `feature/http-1.x` branch. You can see all of those PRs [here](https://github.com/smithy-lang/smithy-rs/pulls?q=is%3Apr%20is%3Aclosed%20base%3Afeature%2Fhttp-1.x). ## 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. --> All CI tests pass with the exception of the semver failures (see below). These failures are all related to the `aws-smithy-compression` crate which is pre-1.0 and had a semver incompatible version bump, so that shouldn't be an issue. ``` checking aws-smithy-compression...failed! --- failure feature_missing: package feature removed or renamed --- Description: A feature has been removed from this package's Cargo.toml. This will break downstream crates which enable that feature. ref: https://doc.rust-lang.org/cargo/reference/semver.html#cargo-feature-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/feature_missing.ron Failed in: feature http-body-1-x in the package's Cargo.toml feature http-body-0-4-x in the package's Cargo.toml --- failure inherent_method_missing: pub method removed or renamed --- Description: A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/inherent_method_missing.ron Failed in: CompressionAlgorithm::into_impl_http_body_0_4_x, previously in file /home/build/workspace/smithy-rs/target/semver-checks/git-base/8c895dfa8dcf82eaffbf2ce44708ff8b2985b58f/aws-sdk/sdk/aws-smithy-compression/src/lib.rs:168 --- failure module_missing: pub module removed or renamed --- Description: A publicly-visible module cannot be imported by its prior path. A `pub use` may have been removed, or the module may have been renamed, removed, or made non-public. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/module_missing.ron Failed in: mod aws_smithy_compression::body::compress::http_body_0_4_x, previously in file /home/build/workspace/smithy-rs/target/semver-checks/git-base/8c895dfa8dcf82eaffbf2ce44708ff8b2985b58f/aws-sdk/sdk/aws-smithy-compression/src/body.rs:41 mod aws_smithy_compression::http::http_body_1_x, previously in file /home/build/workspace/smithy-rs/target/semver-checks/git-base/8c895dfa8dcf82eaffbf2ce44708ff8b2985b58f/aws-sdk/sdk/aws-smithy-compression/src/http.rs:49 mod aws_smithy_compression::http::http_body_0_4_x, previously in file /home/build/workspace/smithy-rs/target/semver-checks/git-base/8c895dfa8dcf82eaffbf2ce44708ff8b2985b58f/aws-sdk/sdk/aws-smithy-compression/src/http.rs:10 --- failure trait_missing: pub trait removed or renamed --- Description: A publicly-visible trait cannot be imported by its prior path. A `pub use` may have been removed, or the trait itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/trait_missing.ron Failed in: trait aws_smithy_compression::http::http_body_1_x::CompressRequest, previously in file /home/build/workspace/smithy-rs/target/semver-checks/git-base/8c895dfa8dcf82eaffbf2ce44708ff8b2985b58f/aws-sdk/sdk/aws-smithy-compression/src/http.rs:54 trait aws_smithy_compression::http::http_body_1_x::CloneCompressRequest, previously in file /home/build/workspace/smithy-rs/target/semver-checks/git-base/8c895dfa8dcf82eaffbf2ce44708ff8b2985b58f/aws-sdk/sdk/aws-smithy-compression/src/http.rs:65 trait aws_smithy_compression::http::http_body_0_4_x::CloneCompressRequest, previously in file /home/build/workspace/smithy-rs/target/semver-checks/git-base/8c895dfa8dcf82eaffbf2ce44708ff8b2985b58f/aws-sdk/sdk/aws-smithy-compression/src/http.rs:26 trait aws_smithy_compression::http::http_body_0_4_x::CompressRequest, previously in file /home/build/workspace/smithy-rs/target/semver-checks/git-base/8c895dfa8dcf82eaffbf2ce44708ff8b2985b58f/aws-sdk/sdk/aws-smithy-compression/src/http.rs:15 ``` ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] For changes to the smithy-rs codegen or runtime crates, I have created a changelog entry Markdown file in the `.changelog` directory, specifying "client," "server," or both in the `applies_to` key. - [x] For changes to the AWS SDK, generated SDK code, or SDK runtime crates, I have created a changelog entry Markdown file in the `.changelog` directory, specifying "aws-sdk-rust" in the `applies_to` key. ---- _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> Co-authored-by: Russell Cohen <rcoh@amazon.com> Co-authored-by: AWS SDK Rust Bot <aws-sdk-rust-primary@amazon.com> Co-authored-by: AWS SDK Rust Bot <97246200+aws-sdk-rust-ci@users.noreply.github.com> Co-authored-by: vcjana <vcjana@amazon.com> Co-authored-by: Jason Gin <67525213+jasgin@users.noreply.github.com> Co-authored-by: Aaron Todd <aajtodd@users.noreply.github.com> Co-authored-by: greenwoodcm <greenwd@amazon.com> Co-authored-by: Jason Gin <jasongin88@gmail.com> Co-authored-by: Aaron J Todd <todaaron@amazon.com> Co-authored-by: Anna H <annahay@amazon.com> Co-authored-by: Ariel Ben-Yehuda <ariel.byd@gmail.com> Co-authored-by: Ariel Ben-Yehuda <arielby@amazon.com> Co-authored-by: Fahad Zubair <fahadzubair@gmail.com> Co-authored-by: Fahad Zubair <fahadzub@amazon.com>
1 parent cfcc39c commit 9d6b6a1

File tree

305 files changed

+21610
-9297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

305 files changed

+21610
-9297
lines changed

.changelog/http-1x.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
applies_to:
3+
- aws-sdk-rust
4+
- client
5+
- server
6+
authors:
7+
- landonxjames
8+
- drganjoo
9+
references:
10+
- smithy-rs#4484
11+
breaking: false
12+
new_feature: true
13+
bug_fix: false
14+
---
15+
16+
All Smithy-rs crates, for both servers and clients, now use the 1.x version of
17+
the `http` crate for all internal processing. Utility methods are still provided
18+
for users to convert between SDK types and both of the `http` 0.x and 1.x types.

.github/workflows/pull-request-bot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ jobs:
118118
./gradlew -Paws.services=+sts,+sso,+ssooidc,+signin,+transcribestreaming,+dynamodb :aws:sdk:assemble
119119
120120
# Copy the Server runtime crate(s) in
121-
cp -r rust-runtime/aws-smithy-http-server rust-runtime/aws-smithy-http-server-python rust-runtime/aws-smithy-http-server-typescript aws/sdk/build/aws-sdk/sdk
121+
cp -r rust-runtime/aws-smithy-http-server rust-runtime/aws-smithy-http-server-python rust-runtime/aws-smithy-http-server-typescript rust-runtime/aws-smithy-legacy-http-server aws/sdk/build/aws-sdk/sdk
122122
123123
pushd aws/sdk/build/aws-sdk
124124
125125
# Remove example crates from workspace
126126
sed -i '/examples/d' Cargo.toml
127127
128128
# Add server runtime crates to the workspace
129-
sed -i 's/"sdk\/sts",/"sdk\/sts","sdk\/aws-smithy-http-server","sdk\/aws-smithy-http-server-python","sdk\/aws-smithy-http-server-typescript",/' Cargo.toml
129+
sed -i 's/"sdk\/sts",/"sdk\/sts","sdk\/aws-smithy-http-server","sdk\/aws-smithy-http-server-python","sdk\/aws-smithy-http-server-typescript","sdk\/aws-smithy-legacy-http-server",/' Cargo.toml
130130
131131
RUSTDOCFLAGS="--cfg docsrs" cargo +${{ env.rust_nightly_version }} doc --all-features --no-deps
132132

aws/SDK_CHANGELOG.next.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@
109109
}
110110
],
111111
"aws-sdk-model": []
112-
}
112+
}

aws/codegen-aws-sdk/src/main/kotlin/software/amazon/smithy/rustsdk/AwsChunkedContentEncodingDecorator.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class AwsChunkedContentEncodingDecorator : ClientCodegenDecorator {
2828
// This decorator must decorate after any of the following:
2929
// - HttpRequestChecksumDecorator
3030
// - HttpRequestCompressionDecorator
31-
override val order: Byte = (minOf(HttpRequestChecksumDecorator.ORDER, HttpRequestCompressionDecorator.ORDER) - 1).toByte()
31+
override val order: Byte =
32+
(minOf(HttpRequestChecksumDecorator.ORDER, HttpRequestCompressionDecorator.ORDER) - 1).toByte()
3233

3334
override fun operationCustomizations(
3435
codegenContext: ClientCodegenContext,
@@ -81,8 +82,8 @@ private fun RuntimeConfig.awsChunked() =
8182
InlineAwsDependency.forRustFile(
8283
"aws_chunked", visibility = Visibility.PUBCRATE,
8384
CargoDependency.Bytes,
84-
CargoDependency.Http,
85-
CargoDependency.HttpBody,
85+
CargoDependency.Http1x,
86+
CargoDependency.HttpBody1x,
8687
CargoDependency.Tracing,
8788
AwsCargoDependency.awsRuntime(this).withFeature("http-02x"),
8889
CargoDependency.smithyRuntimeApiClient(this),

aws/codegen-aws-sdk/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ class AwsPresigningDecorator internal constructor(
170170
rustCrate.mergeFeature(
171171
Feature(
172172
"http-1x",
173-
default = false,
174-
listOf("dep:http-body-1x", "aws-smithy-runtime-api/http-1x"),
173+
default = true,
174+
listOf("aws-smithy-runtime-api/http-1x"),
175175
),
176176
)
177177
}
@@ -204,6 +204,14 @@ class AwsPresignedFluentBuilderMethod(
204204
"SdkError" to RuntimeType.sdkError(runtimeConfig),
205205
)
206206

207+
// Presigning requires both http version features since it pub exposes into_http_02x_request
208+
// and into_http_1x_request functions
209+
private val smithyRuntimeApi =
210+
CargoDependency.smithyRuntimeApiClient(codegenContext.runtimeConfig)
211+
.withFeature("http-02x")
212+
.withFeature("http-1x")
213+
.toType()
214+
207215
override fun section(section: FluentClientSection): Writable =
208216
writable {
209217
if (section is FluentClientSection.FluentBuilderImpl && section.operationShape.hasTrait(PresignableTrait::class.java)) {
@@ -219,7 +227,7 @@ class AwsPresignedFluentBuilderMethod(
219227
*codegenScope,
220228
"OpError" to section.operationErrorType,
221229
"RawResponseType" to
222-
RuntimeType.smithyRuntimeApiClient(runtimeConfig)
230+
smithyRuntimeApi
223231
.resolve("client::orchestrator::HttpResponse"),
224232
) {
225233
renderPresignedMethodBody(section)
@@ -305,13 +313,13 @@ class AwsPresignedFluentBuilderMethod(
305313
"OperationError" to section.operationErrorType,
306314
"RuntimePlugins" to RuntimeType.runtimePlugins(runtimeConfig),
307315
"SharedInterceptor" to
308-
RuntimeType.smithyRuntimeApiClient(runtimeConfig).resolve("client::interceptors")
316+
smithyRuntimeApi.resolve("client::interceptors")
309317
.resolve("SharedInterceptor"),
310318
"SigV4PresigningRuntimePlugin" to
311319
AwsRuntimeType.presigningInterceptor(runtimeConfig)
312320
.resolve("SigV4PresigningRuntimePlugin"),
313321
"StopPoint" to RuntimeType.smithyRuntime(runtimeConfig).resolve("client::orchestrator::StopPoint"),
314-
"USER_AGENT" to CargoDependency.Http.toType().resolve("header::USER_AGENT"),
322+
"USER_AGENT" to CargoDependency.Http1x.toType().resolve("header::USER_AGENT"),
315323
"alternate_presigning_serializer" to
316324
writable {
317325
if (presignableOp.hasModelTransforms()) {
@@ -334,7 +342,7 @@ class AwsPresignedFluentBuilderMethod(
334342
"Layer" to smithyTypes.resolve("config_bag::Layer"),
335343
"RuntimePlugin" to RuntimeType.runtimePlugin(codegenContext.runtimeConfig),
336344
"SharedRequestSerializer" to
337-
RuntimeType.smithyRuntimeApiClient(codegenContext.runtimeConfig)
345+
smithyRuntimeApi
338346
.resolve("client::ser_de::SharedRequestSerializer"),
339347
)
340348
}

aws/codegen-aws-sdk/src/main/kotlin/software/amazon/smithy/rustsdk/AwsRuntimeType.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ object AwsRuntimeType {
3636
RuntimeType.forInlineDependency(
3737
InlineAwsDependency.forRustFile(
3838
"presigning", visibility = Visibility.PUBLIC,
39+
// Requires http_02x because of existing pub *_http_02x_request methods
40+
CargoDependency.Http0x,
3941
CargoDependency.Http1x,
4042
CargoDependency.HttpBody1x,
4143
),

aws/codegen-aws-sdk/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ internal fun RuntimeConfig.awsInlineableHttpRequestChecksum() =
4141
InlineAwsDependency.forRustFile(
4242
"http_request_checksum", visibility = Visibility.PUBCRATE,
4343
CargoDependency.Bytes,
44-
CargoDependency.Http,
45-
CargoDependency.HttpBody,
44+
CargoDependency.Http1x,
45+
CargoDependency.HttpBody1x,
46+
CargoDependency.HttpBodyUtil01x.toDevDependency(),
4647
CargoDependency.Tracing,
47-
AwsCargoDependency.awsRuntime(this).withFeature("http-02x"),
48+
AwsCargoDependency.awsRuntime(this).withFeature("http-1x"),
4849
CargoDependency.smithyChecksums(this),
4950
CargoDependency.smithyHttp(this),
5051
CargoDependency.smithyRuntimeApiClient(this),

aws/codegen-aws-sdk/src/main/kotlin/software/amazon/smithy/rustsdk/HttpResponseChecksumDecorator.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ private fun RuntimeConfig.awsInlineableHttpResponseChecksum() =
4040
InlineAwsDependency.forRustFile(
4141
"http_response_checksum", visibility = Visibility.PUBCRATE,
4242
CargoDependency.Bytes,
43-
CargoDependency.Http,
44-
CargoDependency.HttpBody,
4543
CargoDependency.Tracing,
4644
CargoDependency.smithyChecksums(this),
4745
CargoDependency.smithyHttp(this),

aws/codegen-aws-sdk/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Compani
2121
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.Hound
2222
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.Http1x
2323
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.HttpBody1x
24-
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.HttpBodyUtil
24+
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.HttpBodyUtil01x
2525
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.SerdeJson
2626
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.Smol
2727
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.TempFile
@@ -180,7 +180,7 @@ class S3TestDependencies(private val runtimeConfig: RuntimeConfig) : LibRsCustom
180180
addDependency(FuturesUtil.toDevDependency())
181181
addDependency(HdrHistogram)
182182
addDependency(HttpBody1x.toDevDependency().copy(optional = false))
183-
addDependency(HttpBodyUtil.toDevDependency().copy(optional = false))
183+
addDependency(HttpBodyUtil01x.toDevDependency().copy(optional = false))
184184
addDependency(Smol)
185185
addDependency(TempFile)
186186
addDependency(TracingAppender)

aws/codegen-aws-sdk/src/test/kotlin/software/amazon/smithy/rustsdk/HttpChecksumTest.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ internal class HttpChecksumTest {
172172
Feature(
173173
"http-1x",
174174
default = false,
175-
listOf("dep:http-body-1x", "aws-smithy-runtime-api/http-1x"),
175+
listOf("aws-smithy-runtime-api/http-1x"),
176176
),
177177
)
178178

@@ -188,7 +188,8 @@ internal class HttpChecksumTest {
188188
use #{pretty_assertions}::assert_eq;
189189
use #{SdkBody};
190190
use std::io::Write;
191-
use http_body::Body;
191+
use http_body_1x::Body;
192+
use http_body_util::BodyExt;
192193
use #{HttpRequest};
193194
use #{UaAssert};
194195
use #{UaExtract};
@@ -364,12 +365,16 @@ internal class HttpChecksumTest {
364365
);
365366
assert_eq!(headers.get("content-encoding").unwrap(), "aws-chunked");
366367
367-
let mut body = request.body().try_clone().expect("body is retryable");
368+
let body = request
369+
.body()
370+
.try_clone()
371+
.expect("body is retryable")
372+
.collect()
373+
.await
374+
.expect("body is collectable");
368375
369376
let mut body_data = bytes::BytesMut::new();
370-
while let Some(data) = body.data().await {
371-
body_data.extend_from_slice(&data.unwrap())
372-
}
377+
body_data.extend_from_slice(&body.to_bytes());
373378
374379
let body_string = std::str::from_utf8(&body_data).unwrap();
375380
assert!(body_string.contains("x-amz-checksum-$algoLower:${testDef.trailerChecksum}"));

0 commit comments

Comments
 (0)