Description
Oliver Otzen opened SPR-12173 and commented
If a client is sending a POST message with an empty header 'Content-Type' the request fails with a IllegalArgumentException.
In HttpHeaders Line 305 only null values will be checked, but not empty values.
In the RFC 7231 it is not explicitly forbidden to send an empty 'Content-Type'-header field.
http://tools.ietf.org/html/rfc7231#section-3.1.1.5
Caused by: java.lang.IllegalArgumentException: 'mediaType' must not be empty
at org.springframework.util.Assert.hasLength(Assert.java:136)
at org.springframework.http.MediaType.parseMediaType(MediaType.java:688)
at org.springframework.http.HttpHeaders.getContentType(HttpHeaders.java:305)
at org.springframework.http.server.ServletServerHttpRequest.getHeaders(ServletServerHttpRequest.java:106)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.writeWithMessageConverters(AnnotationMethodHandlerAdapter.java:1026)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.handleHttpEntityResponse(AnnotationMethodHandlerAdapter.java:1014)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.getModelAndView(AnnotationMethodHandlerAdapter.java:940)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:441)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
Example POST from chrome browser:
POST /fileUpload HTTP/1.1
Host: www.example.org
Connection: keep-alive
Content-Length: 393
Origin: http://www.example.org
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
filename: YXBpLWRvY3M=
Content-Type:
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Affects: 3.2.4
Issue Links:
- Spring HTTP clients do not enforce RFC 6265 (cookies in a single header) [SPR-12196] #16810 Spring HTTP clients do not enforce RFC 6265 (cookies in a single header)
- Spring Web should process requests with empty/invalid mime type [SPR-14309] #18881 Spring Web should process requests with empty/invalid mime type
Referenced from: commits d501137, a1c0905, 4ab27d8, 44c52a9, 70412a9, afb0342
3 votes, 4 watchers