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
@@ -630,10 +631,13 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext)
630
631
}
631
632
}
632
633
633
- if (this .content != null && this .contentType != null ) {
634
- MediaType mediaType = MediaType .parseMediaType (this .contentType );
635
- if (MediaType .APPLICATION_FORM_URLENCODED .includes (mediaType )) {
636
- addRequestParams (request , parseFormData (mediaType ));
634
+ if (this .content != null && this .content .length > 0 ) {
635
+ String requestContentType = request .getContentType ();
636
+ if (requestContentType != null ) {
637
+ MediaType mediaType = MediaType .parseMediaType (requestContentType );
638
+ if (MediaType .APPLICATION_FORM_URLENCODED .includes (mediaType )) {
639
+ addRequestParams (request , parseFormData (mediaType ));
640
+ }
637
641
}
638
642
}
639
643
You can’t perform that action at this time.
0 commit comments