Skip to content

When favorPathExtension is false ResourceHttpRequestHandler serves resources with different content type in 4.3 compared to 4.2 [SPR-14577] #19146

Closed
@spring-projects-issues

Description

@spring-projects-issues

Andy Wilkinson opened SPR-14577 and commented

As a result of this change, when favoring of path extensions is disabled ResourceHttpRequestHandler serves static resources with a content type based on the request's accept header. In the referenced Spring Boot issue this leads to HTML being served as application/json as the accept header was Accept: application/json,text/plain,\*/\*. With 4.2.x, the HTML page is served as text/html as expected.

I've attached a small Spring Boot application that reproduces the problem. It's configured to use Spring Framework 4.3.2 in order to reproduce the problem. Removing the override of the spring.version property from the pom will show the old, desired behaviour with Spring Framework 4.2.x.

With Spring Framework 4.3.2:

$ curl -I localhost:8080/ -H "Accept: application/json,text/plain,*/*"
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Last-Modified: Wed, 10 Aug 2016 09:49:22 GMT
Accept-Ranges: bytes
Content-Type: application/json;charset=UTF-8
Content-Language: en-US
Content-Length: 7
Date: Wed, 10 Aug 2016 09:49:32 GMT

With Spring Framework 4.2:

$ curl -I localhost:8080/ -H "Accept: application/json,text/plain,*/*"
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Last-Modified: Wed, 10 Aug 2016 10:44:33 GMT
Accept-Ranges: bytes
Content-Type: text/html;charset=UTF-8
Content-Language: en-US
Content-Length: 7
Date: Wed, 10 Aug 2016 10:44:45 GMT

Affects: 4.3.2

Reference URL: spring-projects/spring-boot#6562

Attachments:

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions