MockHttpServletRequestBuilder reliably detects form body content type again
Issue: SPR-15116
This commit is contained in:
parent
bb9e561934
commit
e88e8f1d09
|
@ -70,6 +70,7 @@ import org.springframework.web.util.UriUtils;
|
|||
* {@code MockHttpServletRequest} can be plugged in via {@link #with(RequestPostProcessor)}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
* @author Arjen Poutsma
|
||||
* @author Sam Brannen
|
||||
* @author Kamill Sokol
|
||||
|
@ -630,10 +631,13 @@ public class MockHttpServletRequestBuilder
|
|||
}
|
||||
}
|
||||
|
||||
if (this.content != null && this.contentType != null) {
|
||||
MediaType mediaType = MediaType.parseMediaType(this.contentType);
|
||||
if (MediaType.APPLICATION_FORM_URLENCODED.includes(mediaType)) {
|
||||
addRequestParams(request, parseFormData(mediaType));
|
||||
if (this.content != null && this.content.length > 0) {
|
||||
String requestContentType = request.getContentType();
|
||||
if (requestContentType != null) {
|
||||
MediaType mediaType = MediaType.parseMediaType(requestContentType);
|
||||
if (MediaType.APPLICATION_FORM_URLENCODED.includes(mediaType)) {
|
||||
addRequestParams(request, parseFormData(mediaType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue