aws_http_client: Copy response headers (#27941)

Shardul Vaidya and Marshall Bowers created

Preemptive fixes required for #26734

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>

Change summary

crates/aws_http_client/src/aws_http_client.rs | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

Detailed changes

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)
         })
     }
 }