From 0a58e54477058a5c9141f9abff552d564598c9ac Mon Sep 17 00:00:00 2001 From: Shardul Vaidya <31039336+5herlocked@users.noreply.github.com> Date: Wed, 2 Apr 2025 15:00:44 -0400 Subject: [PATCH] aws_http_client: Copy response headers (#27941) Preemptive fixes required for #26734 Release Notes: - N/A --------- Co-authored-by: Marshall Bowers --- crates/aws_http_client/src/aws_http_client.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/aws_http_client/src/aws_http_client.rs b/crates/aws_http_client/src/aws_http_client.rs index 149aa57af9..6adb995747 100644 --- a/crates/aws_http_client/src/aws_http_client.rs +++ b/crates/aws_http_client/src/aws_http_client.rs @@ -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) }) } }