Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-3803

Archived artifacts are served with improper mime-types

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • None
    • Platform: All, OS: All

      We use the "Archive build artifacts" to save a number of logs pertaining to the build, these files are
      all text files with a ".log" suffix.

      Regardless of this however, Hudson still serves these files with the 'application/octet-stream' mime-
      type, causing stupid browsers like Firefox to try to download the file instead of render the text.

          [JENKINS-3803] Archived artifacts are served with improper mime-types

          remke added a comment -

          My case is a bit different, but I suspect it has the same code behind it.
          I want to display a xml file from my workspace which has a link to xslt in it.
          The 'view' link displays the text, but without the xslt applied (I can
          understand that). The link to the file itself opens an 'Open with...' dialog,
          because the Content-type is application/octet-stream.
          Can the content-type be automatically detected from the file extension?

          remke added a comment - My case is a bit different, but I suspect it has the same code behind it. I want to display a xml file from my workspace which has a link to xslt in it. The 'view' link displays the text, but without the xslt applied (I can understand that). The link to the file itself opens an 'Open with...' dialog, because the Content-type is application/octet-stream. Can the content-type be automatically detected from the file extension?

          The MIME type mapping comes from the underlying servlet container. Which one do
          you use? Winstone?

          Kohsuke Kawaguchi added a comment - The MIME type mapping comes from the underlying servlet container. Which one do you use? Winstone?

          R. Tyler Croy added a comment -

          I experience this issue when using the default Hudson container, I'm assuming
          that's Winstone

          R. Tyler Croy added a comment - I experience this issue when using the default Hudson container, I'm assuming that's Winstone

          remke added a comment -

          Answering koshuke's question: Yes, I am using the Winstone servlet engine.
          I found (in Winstone's issue list) your request for more default mime types in
          the Winstone resources
          (http://sourceforge.net/tracker/index.php?func=detail&aid=1746201&group_id=98922&atid=622500).

          The mime types in the Winstone properties are:
          WebAppConfig.DefaultMimeTypes=jpg=image/jpeg:jpeg=image/jpeg:gif=image/gif:css=text/css:js=text/javascript:pdf=application/pdf:txt=text/plain:html=text/html:png=image/png:zip=application/zip:jar=application/java-archive

          I added some extra extension/mime-type combinations to the Hudson web.xml, as
          Rick Knowles (Winstone author) suggested.
          That works, but of course my changes will be gone in the next Hudson update.

          Could you add some entries to the Hudson web.xml?

          Some extensions I am missing are:
          xml: text/xml
          xslt: application/xslt+xml or text/xml
          ear: ???? (don't know if a mime-type exists)
          war: ???? (don't know if a mime-type exists)

          Even better would be a way to add your own mappings external to Hudson, but that
          would mean an enhancement to the servlet container (Winstone in my case) not
          Hudson itself.
          Well, maybe I should switch to a servlet container that supports this by
          default, we deploy our own application on Oracle Application Server (Weblogic in
          the future), so I could use that. I like the simplicity of the embedded Winstone
          container though.

          remke added a comment - Answering koshuke's question: Yes, I am using the Winstone servlet engine. I found (in Winstone's issue list) your request for more default mime types in the Winstone resources ( http://sourceforge.net/tracker/index.php?func=detail&aid=1746201&group_id=98922&atid=622500 ). The mime types in the Winstone properties are: WebAppConfig.DefaultMimeTypes=jpg=image/jpeg:jpeg=image/jpeg:gif=image/gif:css=text/css:js=text/javascript:pdf=application/pdf:txt=text/plain:html=text/html:png=image/png:zip=application/zip:jar=application/java-archive I added some extra extension/mime-type combinations to the Hudson web.xml, as Rick Knowles (Winstone author) suggested. That works, but of course my changes will be gone in the next Hudson update. Could you add some entries to the Hudson web.xml? Some extensions I am missing are: xml: text/xml xslt: application/xslt+xml or text/xml ear: ???? (don't know if a mime-type exists) war: ???? (don't know if a mime-type exists) Even better would be a way to add your own mappings external to Hudson, but that would mean an enhancement to the servlet container (Winstone in my case) not Hudson itself. Well, maybe I should switch to a servlet container that supports this by default, we deploy our own application on Oracle Application Server (Weblogic in the future), so I could use that. I like the simplicity of the embedded Winstone container though.

          Any chance you can send us a patch from what you did?

          Kohsuke Kawaguchi added a comment - Any chance you can send us a patch from what you did?

          remke added a comment -

          Created an attachment (id=781)
          Patch for web.xml, modify to your needs

          remke added a comment - Created an attachment (id=781) Patch for web.xml, modify to your needs

          remke added a comment -

          I created a unified diff file for the web.xml. It is very simple, modify to your
          needs.

          remke added a comment - I created a unified diff file for the web.xml. It is very simple, modify to your needs.

          Code changed in hudson
          User: : kohsuke
          Path:
          trunk/hudson/main/war/resources/WEB-INF/web.xml
          trunk/www/changelog.html
          http://fisheye4.cenqua.com/changelog/hudson/?cs=19730
          Log:
          [FIXED JENKINS-3803] In 1.316.

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : kohsuke Path: trunk/hudson/main/war/resources/WEB-INF/web.xml trunk/www/changelog.html http://fisheye4.cenqua.com/changelog/hudson/?cs=19730 Log: [FIXED JENKINS-3803] In 1.316.

          jerryshea added a comment -

          Could we also add this to the web.xml to allow serving up of SVG (my build
          generates some of these)?
          svg=image/svg+xml

          jerryshea added a comment - Could we also add this to the web.xml to allow serving up of SVG (my build generates some of these)? svg=image/svg+xml

          Code changed in jenkins
          User: George Shakhnazaryan
          Path:
          war/src/main/webapp/WEB-INF/web.xml
          http://jenkins-ci.org/commit/jenkins/c1d2c945465d30efb63de7abce51d95289170e63
          Log:
          Adding the video/webm mime type for files with extension .webm. The change is similar to JENKINS-3803, just a different extension.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: George Shakhnazaryan Path: war/src/main/webapp/WEB-INF/web.xml http://jenkins-ci.org/commit/jenkins/c1d2c945465d30efb63de7abce51d95289170e63 Log: Adding the video/webm mime type for files with extension .webm. The change is similar to JENKINS-3803 , just a different extension.

            Unassigned Unassigned
            rtyler R. Tyler Croy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: