Unverified Commit 8aa3a74a authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Remove generic body from `ParseHttpResponse` (#626)

* Remove generic body from `ParseHttpResponse`

* Update CHANGELOG
parent 8011dc32
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
vNext (Month Day Year)
----------------------

**Breaking changes**

- (#626) `ParseHttpResponse` no longer has a generic argument for the body type, but instead, always uses `SdkBody`. This may cause compilation failures for you if you are using Smithy generated types to parse JSON or XML without using a client to request data from a service. The fix should be as simple as removing `<SdkBody>` in the example below:

  Before:
  ```rust
  let output = <Query as ParseHttpResponse<SdkBody>>::parse_loaded(&parser, &response).unwrap();
  ```

  After:
  ```rust
  let output = <Query as ParseHttpResponse>::parse_loaded(&parser, &response).unwrap();
  ```

**New This Week**
- (When complete) Add profile file provider for region (#594, #xyz)


v0.19 (August 3rd, 2021)
------------------------

+3 −6
Original line number Diff line number Diff line
@@ -54,14 +54,11 @@ impl ProvideErrorKind for OperationError {
    }
}

impl<B> ParseHttpResponse<B> for TestOperationParser
where
    B: http_body::Body,
{
impl ParseHttpResponse for TestOperationParser {
    type Output = Result<String, OperationError>;

    fn parse_unloaded(&self, _response: &mut Response<B>) -> Option<Self::Output> {
        if _response.status().is_success() {
    fn parse_unloaded(&self, response: &mut Response<SdkBody>) -> Option<Self::Output> {
        if response.status().is_success() {
            Some(Ok("Hello!".to_string()))
        } else {
            Some(Err(OperationError))
+2 −1
Original line number Diff line number Diff line
@@ -10,12 +10,13 @@ edition = "2018"
[dependencies]
aws-auth = { path = "../../build/aws-sdk/aws-auth" }
aws-http = { path = "../../build/aws-sdk/aws-http" }
aws-hyper = { path = "../../build/aws-sdk/aws-hyper", features = ["test-util"] }
aws-hyper = { path = "../../build/aws-sdk/aws-hyper" }
aws-sdk-dynamodb = { path = "../../build/aws-sdk/dynamodb" }
bytes = "1"
criterion = { version = "0.3.4" }
http = "0.2.4"
serde_json = "1"
smithy-client = { path = "../../build/aws-sdk/smithy-client", features = ["test-util"] }
smithy-http = { path = "../../build/aws-sdk/smithy-http" }
smithy-types = { path = "../../build/aws-sdk/smithy-types" }
tokio = { version = "1", features = ["full", "test-util"]}
+1 −2
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@
use aws_sdk_dynamodb::operation::Query;
use bytes::Bytes;
use criterion::{criterion_group, criterion_main, Criterion};
use smithy_http::body::SdkBody;
use smithy_http::response::ParseHttpResponse;

fn do_bench() {
@@ -23,7 +22,7 @@ fn do_bench() {
        .unwrap();

    let parser = Query::new();
    let output = <Query as ParseHttpResponse<SdkBody>>::parse_loaded(&parser, &response).unwrap();
    let output = <Query as ParseHttpResponse>::parse_loaded(&parser, &response).unwrap();
    assert_eq!(2, output.count);
}

+1 −2
Original line number Diff line number Diff line
@@ -277,14 +277,13 @@ class HttpProtocolTestGenerator(
            let parsed = parser.parse_unloaded(&mut http_response);
            let parsed = parsed.unwrap_or_else(|| {
                let http_response = http_response.map(|body|#{bytes}::copy_from_slice(body.bytes().unwrap()));
                <#{op} as #{parse_http_response}<#{sdk_body}>>::parse_loaded(&parser, &http_response)
                <#{op} as #{parse_http_response}>::parse_loaded(&parser, &http_response)
            });
        """,
            "op" to operationSymbol,
            "bytes" to RuntimeType.Bytes,
            "parse_http_response" to CargoDependency.SmithyHttp(protocolConfig.runtimeConfig).asType()
                .member("response::ParseHttpResponse"),
            "sdk_body" to RuntimeType.sdkBody(runtimeConfig = protocolConfig.runtimeConfig)
        )
        if (expectedShape.hasTrait<ErrorTrait>()) {
            val errorSymbol = operationShape.errorSymbol(protocolConfig.symbolProvider)
Loading