Skip to content

Fix AWSCRTHTTPClient request bodies for HTTP/1.1 connections#697

Merged
arandito merged 2 commits into
smithy-lang:developfrom
arandito:fix-crt-h1-services
May 14, 2026
Merged

Fix AWSCRTHTTPClient request bodies for HTTP/1.1 connections#697
arandito merged 2 commits into
smithy-lang:developfrom
arandito:fix-crt-h1-services

Conversation

@arandito
Copy link
Copy Markdown
Contributor

@arandito arandito commented May 13, 2026

Description

Previously, our AWSCRTHTTPClient attached request bodies via the CRT's request_body_generator parameter, which is only supported for HTTP/2 connections (source). This caused generated clients that only support HTTP/1.1 to throw the following error when making body-bearing requests:

smithy_core.exceptions.SmithyError: 2056 (AWS_ERROR_HTTP_MISSING_BODY_STREAM): Given the provided headers (ex: Content-Length), a body is expected.

This PR adds logic that routes HTTP/1.1 connections to attach bodies through the body_stream parameter on the request itself and keeps the generator path for HTTP/2.

Testing

  • Generated H1-only service (STS) and confirmed calls no longer raise AWS_ERROR_HTTP_MISSING_BODY_STREAM
  • Confirmed existing client integration tests succeed with changes

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

@arandito arandito requested a review from a team as a code owner May 13, 2026 23:03
@arandito arandito changed the title smithy-http: Fix AWSCRTHTTPClient request bodies for HTTP/1.1 connections Fix AWSCRTHTTPClient request bodies for HTTP/1.1 connections May 13, 2026
Copy link
Copy Markdown
Contributor

@Alan4506 Alan4506 left a comment

Choose a reason for hiding this comment

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

LTGM overall. Just wondering if there is a roadmap / tracking issue on the aws-crt-python side about when they will support HTTP/1.1 streaming request bodies, so we can switch this back from buffering.

request_body_generator=body_generator,
)
# request_body_generator is HTTP/2-only in CRT; HTTP/1.1 must use body_stream
if connection.version == crt_http.HttpVersion.Http2:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: do we want to use "is" instead of "==" to align with if force_http_2 and connection.version is not crt_http.HttpVersion.Http2:

if force_http_2 and connection.version is not crt_http.HttpVersion.Http2:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, yea enums should be compared based on identity so I can switch that. I will update this one I get additional feedback in case there are larger changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 97aef6e

@arandito
Copy link
Copy Markdown
Contributor Author

LTGM overall. Just wondering if there is a roadmap / tracking issue on the aws-crt-python side about when they will support HTTP/1.1 streaming request bodies, so we can switch this back from buffering.

Not yet. I am going to ask their team if this is on their roadmap as a follow-up. I'm not sure if there are protocol-level limitations on their side for why they can't support body generators for H1. This solution is an immediate fix to unblock future H1-only clients but ideally we can revert back to their generators if they add support in the future.

jonathan343
jonathan343 previously approved these changes May 14, 2026
@arandito arandito merged commit c337791 into smithy-lang:develop May 14, 2026
8 checks passed
@arandito arandito deleted the fix-crt-h1-services branch May 14, 2026 19:11
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.

3 participants