Skip to content

Commit

Permalink
Allow expected content-type to ignore parameters
Browse files Browse the repository at this point in the history
Fixes: #3471
  • Loading branch information
djedward committed Apr 11, 2024
1 parent 129b85d commit 6822765
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
# references = ["smithy-rs#920"]
# meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"}
# author = "rcoh"

[[smithy-rs]]
message = """
Content-Type header validation now ignores parameter portion of media types.
"""
references = ["smithy-rs#3471","smithy-rs#3576"]
meta = { "breaking" = false, "tada" = false, "bug" = true, target = "server" }
authors = ["djedward"]

[[aws-sdk-rust]]
message = """
Fixes the identity resolver types (`credentials_provider()` and `token_provider()`) from `SdkConfig` to have
Expand All @@ -19,7 +28,6 @@ references = ["smithy-rs#3427"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
authors = ["aajtodd"]


[[smithy-rs]]
message = """
`SharedIdentityResolver` now respects an existing cache partition when the `ResolveIdentity` implementation
Expand Down
9 changes: 8 additions & 1 deletion rust-runtime/aws-smithy-http-server/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn content_type_header_classifier(
.parse::<mime::Mime>()
// `expected_content_type` comes from the codegen.
.expect("BUG: MIME parsing failed, `expected_content_type` is not valid. Please file a bug report under https://github.com/smithy-lang/smithy-rs/issues");
if expected_content_type != found_mime {
if expected_content_type != found_mime.essence_str() {
return Err(MissingContentTypeReason::UnexpectedMimeType {
expected_mime: Some(expected_mime),
found_mime: Some(found_mime),
Expand Down Expand Up @@ -257,6 +257,13 @@ mod tests {
assert!(matches!(result.unwrap_err(), MissingContentTypeReason::ToStrError(_)));
}

#[test]
fn valid_content_type_header_classifier_http_params() {
let request = req_content_type("application/json; charset=utf-8");
let result = content_type_header_classifier_http(&request, EXPECTED_MIME_APPLICATION_JSON);
assert!(result.is_ok());
}

#[test]
fn valid_accept_header_classifier_multiple_values() {
let valid_request = req_accept("text/strings, application/json, invalid");
Expand Down

0 comments on commit 6822765

Please sign in to comment.