Fix AWSCRTHTTPClient request bodies for HTTP/1.1 connections#697
Conversation
Alan4506
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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.
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. |
Description
Previously, our
AWSCRTHTTPClientattached request bodies via the CRT'srequest_body_generatorparameter, 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:This PR adds logic that routes HTTP/1.1 connections to attach bodies through the
body_streamparameter on the request itself and keeps the generator path for HTTP/2.Testing
AWS_ERROR_HTTP_MISSING_BODY_STREAMBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.