Skip to content

Add http-1x examples for server SDK usage#4377

Open
drganjoo wants to merge 26 commits intomainfrom
fahadzub/http-1.x-examples
Open

Add http-1x examples for server SDK usage#4377
drganjoo wants to merge 26 commits intomainfrom
fahadzub/http-1.x-examples

Conversation

@drganjoo
Copy link
Contributor

@drganjoo drganjoo commented Nov 2, 2025

This commit updates examples to demonstrate server SDK usage with both http@0.2.x
and http@1.x, supporting the http-1x migration effort.

Changes

New Directories

  • legacy/: Complete set of examples using http@0.2.x/hyper@0.14 with
    aws-smithy-legacy-http-server. These examples preserve the original behavior
    for users not yet ready to migrate.

  • pokemon-service-server-skd-patch/: Compatibility layer and patches for
    bridging http@0 and http@1 types in server SDK.

Updated Examples

Modified existing examples to use http@1.x/hyper@1.x:

  • pokemon-service: Main service example updated for http@1
  • pokemon-service-tls: TLS example with hyper 1.x compatibility
  • pokemon-service-lambda: Lambda example updated for http@1
  • pokemon-service-client-usage: Client examples updated
  • pokemon-service-common: Common utilities updated

Key Updates

  • Cargo.toml files updated with http@1.x and hyper@1.x dependencies
  • Server initialization code updated for hyper 1.x API changes
  • Test helpers updated to support both HTTP versions
  • Connector and middleware examples updated for new hyper API

Testing

Examples can be run with both HTTP versions to verify compatibility.

Relates to #3362

landonxjames and others added 21 commits June 25, 2025 11:10
## 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 -->
The first steps to defaulting to `http-1x` dependencies instead of
`http-02x`

## Description
<!--- Describe your changes in detail -->
For this PR I updated the dependencies on SDK crates to enable their
`http-1x` features and worked backwards from there fixing the things
that broke (this would be easier to see if the diff was working but it
seems to be broken for feature branches after the new ECR update). This
involved:
* Updating the `http_request_checksum` inlineable to use `http-1x` types
(and removing the `http-1x` feature since it is no longer needed and
wasn't a "real" feature to begin with
* Creating a new `pub mod content_encoding_http_1x` module in the
`aws-runtime` crate. Most logic here is dedicated to implementing the
`http_body_1x::Body` trait for `AwsChunkedBody`. I initially considered
keeping this in the existing `content_encoding` module, but with the
current feature flags and all of the changes I had to make it felt
cleaner to break it out.
* Update body polling logic for `ChecksumBody` calculation and
validation for `http-1x` types


## 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. -->
Updated existing tests and added new ones for `http-1x` types

## TODOs
Future PRs will
* Update code generation logic in codegen-core to use `http-1x`
* Remove pre-1.0 `http` dependencies (anywhere they aren't re-exported)
* Normalize dependency names to `http-1x`, `http-02x`, etc

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
## Motivation and Context
We released the feature [in this
release](https://github.com/awslabs/aws-sdk-rust/releases/tag/release-2025-06-12),
but till the infrastructure is fully ready, we'll temporarily revert the
functionality.

## Testing
- CI

## Checklist
- [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._
## Description
This PR makes Rpc V2 CBOR a compatible protocol for `awsQuery` using
`awsQueryCompatible` trait, as described in the `Important` section in
[this
page](https://smithy.io/2.0/aws/protocols/aws-query-protocol.html#aws-protocols-awsquerycompatible-trait).

Previously, the implementation for `awsQueryCompatible` was tightly
coupled to `awsJson1_0`. This PR makes the implementation a bit more
abstract so that the implementation can support more target protocols
generically.

## Testing
- CI
- Made `AwsQueryCompatibleTest` parameterized tests to support RpcV2Cbor
and verified against modified cloudwatch service model (with
`awsQueryCompatible` trait applied). ~Tests for RpcV2Cbor is commented
out till #4185 is merged~.

## 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._
## 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 -->
Continuing the work to default to `http-1x` types under the hood. 

## Description
<!--- Describe your changes in detail -->
This is unfortunately an enormous PR (at least in terms of files
touched, not total lines). The vast majority of changes are just
replacing references to `http_02x` with `http_1x` or `http_body_04x`
with `http_body_1x` and updating code or feature flags to match.

The primary functional changes are in the vicintiy of
`rust-runtime/aws-smithy-types/src/body.rs`, updating methods for
`SdkBody` to understand `http_1x` types. This required several changes:
* Add a new `HttpBody1` variant to the `enum BoxBody`
* Update `SdkBody::from_body_1_x` to construct a `HttpBody1` variant
instead of the `HttpBody04` variant it was previously
* Add a new `trailers: Option<VecDeque<http_1x::HeaderMap>>` field to
`SdkBody` to cache polled trailers (`http_body_1x` doesn't allow polling
trailers separately, but `SdkBody` does, so we have to cache at least
the first trailer frame if it is encountered while polling the body)
* Update `SdkBody::{poll_next, poll_next_trailers}` to work with the new
`HttpBody1x` variant.

## 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. -->
Updated most existing tests to use `http-1x` types (Although I have
almost certainly missed some)

Note that some tests are failing here and that is expected:
* Semver tests: we have changed/deleted some `http_02x` trait impls in
pre-1.0 crates, so we expect these to fail
* Server tests: I haven't touched these and will work with Fahad to get
them updated

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
Note: as of this merge aws-smithy-checksums/src/body/calculate.rs is broken

I need to reconcile the changes from #4181 and #4200, but I am going to
do that in a separate commit so I can get it PRed without all the extraneous
merge from main bits
…4204)

## 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 -->
There were some conflicts around checksum changes made in
#4200 while merging main
back into the `feature/http-1.x` branch. This PR reconciles those
changes

----

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

Fix sigv4 test issues
## 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 -->
Request from @drganjoo 

>Also, in feature/http-1.x could we please bump version of
aws-smithy-http to 0.63.x instead of
[0.62.4](https://github.com/smithy-lang/smithy-rs/blob/feature/http-1.x/rust-runtime/aws-smithy-http/Cargo.toml#L3).
This way on the server side we can keep on relying on 0.62.x to have
http/0.x support for a while. Thanks.

Note: I merged main back into the base `feature/http-1.x` branch as part
of making this change

## 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. -->

Failing tests are all server related and expected since the server side
of the codebase hasn't done this upgrade yet.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
@drganjoo drganjoo requested review from a team as code owners November 2, 2025 20:42
Comment on lines 222 to 224
## Client-Side Changes

### HTTP Client Connector Setup
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to call out that client/server http versions are totally decoupled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to check with the SDK team on this section. For the time being I am removing it.

### 3. Request Handling

Most request handling code remains the same thanks to smithy-rs abstractions:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably no need to bother calling this out.

@@ -0,0 +1,54 @@
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[allow(clippy::unnecessary_wraps)]
pub async fn de_check_health_http_request<B>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you meant to check in this entire directory

## Motivation and Context
Merge the latest main to the `feature/http-1.x` branch, plus replace
http-0.x constructs with http-1.x constructs as described in [Tips for
merging to
feature/http-1.x](#4384)

## Testing
- CI: ignore server related failures and semver hazard failure (the type
being complained about `Uri` isn't exposed since its enclosing module
`request` isn't exposed as pub, which confuses the semver hazard check)

----

_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: Landon James <lnj@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>
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

ysaito1001 and others added 3 commits November 18, 2025 13:19
## Motivation and Context
Merge the main branch to the `feature/http-1.x` branch. It takes all
from the main branch except for
[this](#4392 (comment)),
which is replaced by `http-1.x` construct.


----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
## 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 -->

## Description
<!--- Describe your changes in detail -->

## 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. -->

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] 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.
- [ ] 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>
Support for `http@1.x`/`hyper@1.x` in `aws-smithy-http-server` runtime crate for the server.

## Key Changes
### 1. Dependency Upgrades
- **http**: `0.2.9` → `1.x`
- **http-body**: `0.4.5` → `1.0`
- **hyper**: `0.14.26` → `1.x` (with `server`, `http1`, `http2`
features)
- **hyper-util**: Added `0.1` for server utilities (`server-auto`, `server-graceful`, etc.)
- **http-body-util**: Added `0.1` for body utilities
- **tower-http**: `0.3` → `0.6`
- **lambda_http**: `0.8.4` → `1` (for AWS Lambda support)

Updated `aws-smithy-types` to use `http-body-1-x` feature instead of `http-body-0-4-x`.

### 2. New `serve` Module
Added a comprehensive `serve` module (inspired by `axum::serve`) that provides:
- **Simple server API**: Ergonomic `serve(listener, service)` function
- **Connection limiting**: Built-in `limit_connections()` via`ListenerExt`
- **Graceful shutdown**: Zero-cost when unused, opt-in with `.with_graceful_shutdown()`
- **Hyper customization**: `.configure_hyper()` for protocol and performance tuning

## Migration Impact

**Breaking Change**: This updates the public API to use `http@1.x` types (`http::Request`, `http::Response`, etc.).
@drganjoo drganjoo force-pushed the fahadzub/http-1.x-examples branch from 21d6619 to 13d6532 Compare December 8, 2025 14:09
@drganjoo drganjoo force-pushed the fahadzub/http-1.x-examples branch from 13d6532 to 448b981 Compare December 8, 2025 14:16
Base automatically changed from feature/http-1.x to main January 24, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants