Multipart request to create entity and content in single request fails with http 400
Closed this issue · 1 comments
NielsCW commented
Describe the bug
Performing a multipart/form-data
request to the endpoint to create entity and content in single request fails with 400 Bad Request
To Reproduce
- Perform a httpie request using
http --print HhBb --form <url> foo=bar content@test.txt
- The server responds with a http
400 Bad Request
The application fails at this line because the Content-Type
header has value multipart/form-data;boundary=8c...37;charset=UTF-8
Expected behavior
Succeeding to create entity with a 201 Created
tgeens commented
Note there are 2 parameters appended to the Content-Type
, which are not covered by spring-content mockmvc-based tests:
boundary=...
is appended by (any) httpclient, mockmvc does not, because it operates at a higher abstraction levelcharset=UTF-8
is automatically appended byOrderedCharacterEncodingFilter
(viaHttpEncodingAutoConfiguration
) in an auto-configuration scenario, but is not loaded viaMockMvcBuilders.webAppContextSetup(context).build()