Skip to content

Commit

Permalink
Return 415 rather than 400 on Urlencoded Content-Type mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
mpalmer committed Apr 15, 2024
1 parent e518170 commit b6d38f0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion actix-web/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ impl ResponseError for UrlencodedError {
match self {
Self::Overflow { .. } => StatusCode::PAYLOAD_TOO_LARGE,
Self::UnknownLength => StatusCode::LENGTH_REQUIRED,
Self::ContentType => StatusCode::UNSUPPORTED_MEDIA_TYPE,
Self::Payload(err) => err.status_code(),
_ => StatusCode::BAD_REQUEST,
}
Expand Down Expand Up @@ -232,7 +233,7 @@ mod tests {
let resp = UrlencodedError::UnknownLength.error_response();
assert_eq!(resp.status(), StatusCode::LENGTH_REQUIRED);
let resp = UrlencodedError::ContentType.error_response();
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
assert_eq!(resp.status(), StatusCode::UNSUPPORTED_MEDIA_TYPE);
}

#[test]
Expand Down

0 comments on commit b6d38f0

Please sign in to comment.