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:
parent
8539e23018
commit
0a58e54477
1 changed files with 12 additions and 5 deletions
|
@ -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::orchestrator::{HttpRequest as AwsHttpRequest, HttpResponse};
|
||||||
use aws_smithy_runtime_api::client::result::ConnectorError;
|
use aws_smithy_runtime_api::client::result::ConnectorError;
|
||||||
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
|
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 aws_smithy_types::body::SdkBody;
|
||||||
use futures::AsyncReadExt;
|
use futures::AsyncReadExt;
|
||||||
use http_client::{AsyncBody, Inner};
|
use http_client::{AsyncBody, Inner};
|
||||||
|
@ -52,10 +52,17 @@ impl AwsConnector for AwsHttpConnector {
|
||||||
let (parts, body) = response.into_parts();
|
let (parts, body) = response.into_parts();
|
||||||
let body = convert_to_sdk_body(body, handle).await;
|
let body = convert_to_sdk_body(body, handle).await;
|
||||||
|
|
||||||
Ok(HttpResponse::new(
|
let mut response =
|
||||||
StatusCode::try_from(parts.status.as_u16()).unwrap(),
|
HttpResponse::new(StatusCode::try_from(parts.status.as_u16()).unwrap(), body);
|
||||||
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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue