File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
spring-test/src/main/java/org/springframework/test/web/servlet/request Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 70
70
* {@code MockHttpServletRequest} can be plugged in via {@link #with(RequestPostProcessor)}.
71
71
*
72
72
* @author Rossen Stoyanchev
73
+ * @author Juergen Hoeller
73
74
* @author Arjen Poutsma
74
75
* @author Sam Brannen
75
76
* @author Kamill Sokol
@@ -633,10 +634,13 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext)
633
634
}
634
635
}
635
636
636
- if (this .content != null && this .contentType != null ) {
637
- MediaType mediaType = MediaType .parseMediaType (this .contentType );
638
- if (MediaType .APPLICATION_FORM_URLENCODED .includes (mediaType )) {
639
- addRequestParams (request , parseFormData (mediaType ));
637
+ if (this .content != null && this .content .length > 0 ) {
638
+ String requestContentType = request .getContentType ();
639
+ if (requestContentType != null ) {
640
+ MediaType mediaType = MediaType .parseMediaType (requestContentType );
641
+ if (MediaType .APPLICATION_FORM_URLENCODED .includes (mediaType )) {
642
+ addRequestParams (request , parseFormData (mediaType ));
643
+ }
640
644
}
641
645
}
642
646
You can’t perform that action at this time.
0 commit comments