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

          R. Tyler Croy created issue -

          Jesse Glick added a comment -

          You can click the "view" link to see it as text.

          Jesse Glick added a comment - You can click the "view" link to see it as text.

          R. Tyler Croy added a comment -

          On the build page, there aren't any "view" links (unless I'm really that daft)

          The list of build artifacts contain direct links to the artifacts, as well as the little "fingerprint" icon.

          The "view" ilnk in the workspace viewer doesn't really help for looking at build artifacts for older
          builds, only the most recent one.

          R. Tyler Croy added a comment - On the build page, there aren't any "view" links (unless I'm really that daft) The list of build artifacts contain direct links to the artifacts, as well as the little "fingerprint" icon. The "view" ilnk in the workspace viewer doesn't really help for looking at build artifacts for older builds, only the most recent one.

          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?
          Kohsuke Kawaguchi made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          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

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

              Created:
              Updated:
              Resolved: