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 7070 * {@code MockHttpServletRequest} can be plugged in via {@link #with(RequestPostProcessor)}.
7171 *
7272 * @author Rossen Stoyanchev
73+ * @author Juergen Hoeller
7374 * @author Arjen Poutsma
7475 * @author Sam Brannen
7576 * @author Kamill Sokol
@@ -633,10 +634,13 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext)
633634 }
634635 }
635636
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+ }
640644 }
641645 }
642646
You can’t perform that action at this time.
0 commit comments