aws_http_client: Copy response headers (#27941)

Preemptive fixes required for #26734

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
Shardul Vaidya 2025-04-02 15:00:44 -04:00 committed by GitHub
parent 8539e23018
commit 0a58e54477
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,7 +9,7 @@ use aws_smithy_runtime_api::client::http::{
use aws_smithy_runtime_api::client::orchestrator::{HttpRequest as AwsHttpRequest, HttpResponse};
use aws_smithy_runtime_api::client::result::ConnectorError;
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
use aws_smithy_runtime_api::http::StatusCode;
use aws_smithy_runtime_api::http::{Headers, StatusCode};
use aws_smithy_types::body::SdkBody;
use futures::AsyncReadExt;
use http_client::{AsyncBody, Inner};
@ -52,10 +52,17 @@ impl AwsConnector for AwsHttpConnector {
let (parts, body) = response.into_parts();
let body = convert_to_sdk_body(body, handle).await;
Ok(HttpResponse::new(
StatusCode::try_from(parts.status.as_u16()).unwrap(),
body,
))
let mut response =
HttpResponse::new(StatusCode::try_from(parts.status.as_u16()).unwrap(), body);
let headers = match Headers::try_from(parts.headers) {
Ok(headers) => headers,
Err(err) => return Err(ConnectorError::other(err.into(), None)),
};
*response.headers_mut() = headers;
Ok(response)
})
}
}