Skip to content

Mallforme Content-Type is not translated to 415 status code [SPR-10982] #15610

@spring-projects-issues

Description

@spring-projects-issues

Jan Dudek opened SPR-10982 and commented

I believe there's a glitch in org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver#readWithMessageConverters(...). At the beginning of this method the Content-Type header must be obtained:

MediaType contentType = inputMessage.getHeaders().getContentType();
if (contentType == null) {
    contentType = MediaType.APPLICATION_OCTET_STREAM;
}

If the getContentType() call fails (for example for Content-Type: Hello), a InvalidMediaTypeException is thrown.

I believe this exception should be caught here and re-thrown as HttpMediaTypeNotSupportedException which would be eventually translated to a 415 http status code (since in my opinion this is a 415 situation).


Affects: 3.2.4

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions