I had a similar problem with the Spring Boot application. My Spring Boot application is a simple Dispatcher servlet that reads the request body and processes it.
In my case, the client ( curl ) sets the header of the application content type / x -www-form-urlencoded if -d {some-data} used on the curl command line and does not set the header of a specific content type via -Hcontent-type=some-other-media-type .
Inside the Apache Catalina servlet that Spring starts, the Request class performs the following test in parseParameters()
if (!("application/x-www-form-urlencoded".equals(contentType))) { success = true; return; }
For other values, the content-type Request returns here by executing.
However, if the content type matches application/x-www-form-urlencoded , the Request continues:
try { if (readPostBody(formData, len) != len) { parameters.setParseFailedReason(FailReason.REQUEST_BODY_INCOMPLETE); return; } } catch (....)
which will consume the body . So in my case, although my servlet does nothing but call request.getInputStream() , and try read() from it, it's too late - the Request runtime already reads the input and makes it not buffer or unread. The only workaround is to set a different content-type .
Criminal OrderedHiddenHttpMethodFilter(HiddenHttpMethodFilter).doFilterInternal(HttpServletRequest, HttpServletResponse, FilterChain) line 70
which searches for the query parameter "_method" .
I managed to disable the filter by adding
@Bean public FilterRegistrationBean registration(HiddenHttpMethodFilter filter) { FilterRegistrationBean registration = new FilterRegistrationBean(filter); registration.setEnabled(false); return registration; }
(which was used to solve another problem )
djb Dec 15 '15 at 3:19 2015-12-15 03:19
source share