Skip to content

Bad Content-Type for static resources in Spring Web Reactive [SPR-14999] #19566

Closed

Description

@spring-projects-issues

Daniel Fernández opened SPR-14999 and commented

Scenario

A web application using Spring 5.0.0.BUILD-SNAPSHOT, Spring Boot 2.0.0.BUILD-SNAPSHOT and Spring Web Reactive does server-side rendering and needs to serve static resources, such as images and CSS style sheet files.

Server is Tomcat (though it seems to affect all servers, or at least several).

Observed Results

All static resources: images, CSSs, etc, are being served with Content-Type: application/octet-stream. This causes e.g. CSS style sheets not to be rendered by browsers:

See the returned headers, using httpie:

$ http http://localhost:8080/css/stsm.css
HTTP/1.1 200
Accept-Ranges: bytes
Cache-Control: max-age=0
Content-Length: 2518
Content-Type: application/octet-stream
Date: Thu, 08 Dec 2016 23:42:12 GMT
Last-Modified: Thu, 08 Dec 2016 23:24:46 GMT

(content follows)...

Example Repository

I'm creating a Spring Web Reactive-enabled version of Thymeleaf's STSM example application at the thymeleaf/thymeleafexamples-stsm-reactive repository on GitHub: https://github.com/thymeleaf/thymeleafexamples-stsm-reactive/tree/SPR-14999 (tag: SPR-14999)

It can be executed with mvn -U clean compile spring-boot:run. The URL shown above (http://localhost:8080/css/stsm.css) can be used for testing this issue.


Affects: 5.0 M3

Reference URL: https://github.com/thymeleaf/thymeleafexamples-stsm-reactive/tree/SPR-14999

Issue Links:

Activity

  1. spring-projects-issues commented on Dec 9, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    Without an explicit registration this can only come from a JAF lookup, e.g. with org/springframework/mail/javamail/mime.types which is in spring-context-support. I can confirm that with spring-context-support it works. I haven't yet confirmed if a Spring Boot 1.4 web starter application has spring-context-support but I'm guessing not. In the Servlet API we can also perform a media type lookup through the ServletContext and that's probably the reason for the difference.

    The question now is what the best way to address this is /cc Brian Clozel.

  2. spring-projects-issues commented on Dec 9, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Brian Clozel commented

    I can manage the spring-context-support dependency on the starter itself.
    Note that we have incoming changes for this (recently rescheduled to RC1) with #19474.

    Can we close this issue in favor of #19474 ?

  3. spring-projects-issues commented on Dec 9, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    Yes #19474 looks like a good solution and it wouldn't be necessary to have spring-context-support in the starter, or is there another reason for that?

  4. spring-projects-issues commented on Dec 9, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    Resolving in favor of #19474.

  5. added
    type: bug
    status: duplicate
    in: web
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webstatus: duplicate

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions