Skip to content

Snippets for a multipart request documented with WebTestClient include both the raw body and the parts - #1093

Open
chuuminggg wants to merge 1 commit into
spring-projects:4.0.xfrom
chuuminggg:gh-1075-webtestclient-multipart
Open

chuuminggg wants to merge 1 commit into
spring-projects:4.0.xfrom
chuuminggg:gh-1075-webtestclient-multipart

Conversation

@chuuminggg

@chuuminggg chuuminggg commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes gh-1075

This goes with the first option from the issue. When the request's parts can be read, WebTestClientRequestConverter now creates the request without content and removes the boundary from the Content-Type header, so it looks like the request that MockMvcRequestConverter creates. The snippets themselves aren't changed. If the body can't be read as parts, the request is left as it was.

With this change, the existing multipart() integration test produces a curl snippet with only the -F options, an HTTPie snippet without the piped body, and an HTTP request snippet with a single boundary. I've updated the test to check all three, and I ran the curl command against a local server to make sure that curl accepts it and sends both parts.

RestTestClientRequestConverter in main has the same problem. I haven't touched it here, but I can open a separate PR for it if you'd like.

Previously, a multipart request documented with WebTestClient had both
its raw body and its parts. This produced curl and HTTPie snippets that
could not be run and an HTTP request snippet with two boundaries.

The request is now created without content and without the boundary,
as is done for MockMvc.

Fixes spring-projectsgh-1075

Signed-off-by: chuuminggg <rorrxr@naver.com>
@chuuminggg
chuuminggg force-pushed the gh-1075-webtestclient-multipart branch from 342e4a0 to f6900c2 Compare November 16, 2026 13:44

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants