Unverified Commit a50c966e authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

change http checksums to be base64 encoded (#615)

* change http checksums to be base64 encoded

due to a misreading of the spec, the http checksums where hex encoded when they should actually be base64 encoded

* Update changelog
parent 6201a383
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
## vNext (Month Day Year)
**New This Week**
- :bug: Correctly encode HTTP Checksums using base64 instead of hex. Fixes aws-sdk-rust#164. (#615)
- (When complete) Add profile file provider for region (#594, #xyz)

## v0.18.1 (July 27th 2021)
+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ apply PutBucketLifecycleConfiguration @httpRequestTests([
        headers: {
            // we can assert this, but when this test is promoted, it can't assert
            // on the exact contents
            "content-md5": "b14bbeb8064f913b40c4975a03ef6e4a",
            "content-md5": "sUu+uAZPkTtAxJdaA+9uSg==",
        },
        bodyMediaType: "application/xml",
        body: """
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ map XmlMapsNestedNestedNamespaceInputOutputMap {
    params: {
        field: "hello"
    },
    headers: { "Content-Md5": "240240a9803ad7032101319e42a45c31" },
    headers: { "Content-Md5": "JAJAqYA61wMhATGeQqRcMQ==" },
    protocol: "aws.protocols#restXml"
}])
@httpChecksumRequired
+3 −1
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ import software.amazon.smithy.rust.codegen.rustlang.Writable
import software.amazon.smithy.rust.codegen.rustlang.asType
import software.amazon.smithy.rust.codegen.rustlang.rustTemplate
import software.amazon.smithy.rust.codegen.rustlang.writable
import software.amazon.smithy.rust.codegen.smithy.RuntimeType
import software.amazon.smithy.rust.codegen.smithy.customize.OperationCustomization
import software.amazon.smithy.rust.codegen.smithy.customize.OperationSection
import software.amazon.smithy.rust.codegen.smithy.generators.ProtocolConfig
@@ -46,13 +47,14 @@ class HttpChecksumRequiredGenerator(
                        let checksum = #{md5}::compute(data);
                        req.headers_mut().insert(
                            #{http}::header::HeaderName::from_static("content-md5"),
                            format!("{:x}", checksum).parse().expect("checksum is valid header value")
                            #{base64_encode}(&checksum[..]).parse().expect("checksum is valid header value")
                        );
                        Result::<_, #{BuildError}>::Ok(req)
                    })?;
                """,
                    "md5" to CargoDependency.Md5.asType(),
                    "http" to CargoDependency.Http.asType(),
                    "base64_encode" to RuntimeType.Base64Encode(protocolConfig.runtimeConfig),
                    "BuildError" to protocolConfig.runtimeConfig.operationBuildError()
                )
            }