Skip to content

Commit

Permalink
fix(ffi): annotate body in raw body branch
Browse files Browse the repository at this point in the history
If the content type was not otherwise handled,
`OptionalBody::from(&str)` was used. This sets the content type
associated with the body to `None` irrespective of the content type
passed through to `process_body`.

This fixes the issue by ensuring the `OptionalBody::Present` is created
with the appropriate content type.

Signed-off-by: JP-Ellis <[email protected]>
  • Loading branch information
JP-Ellis committed Aug 30, 2024
1 parent 73a1910 commit 0097515
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rust/pact_ffi/src/mock_server/handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,11 @@ fn process_body(
_ => {
// We either have no content type, or an unsupported content type.
trace!("Raw body");
OptionalBody::from(body)
if body.is_empty() {
OptionalBody::Empty
} else {
OptionalBody::Present(Bytes::from(body.to_owned()), content_type, None)
}
}
}
}
Expand Down

0 comments on commit 0097515

Please sign in to comment.