Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4421

content type (mime type) detection in ResourceStreamResource has false fallback

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 1.5.4
    • Fix Version/s: None
    • Component/s: wicket
    • Labels:
      None

      Description

      the content type (or mime type) detectiong deliveres a wrong mime type, if the file name is set, but the mime type is not know from the application.

      ResourceStreamResource Line 148 and the followings:

      final String contentType;
      if (fileName != null && Application.exists())

      { contentType = Application.get().getMimeType(fileName); }

      else

      { contentType = stream.getContentType(); }

      data.setContentType(contentType);

      When the mime type is not know from the application it is set to null and indifferent if the stream knows the correct mime type or not.
      I think the stream should be used as fallback if there is no mime type registered at the application, see:

      String contentType = null;
      if (fileName != null && Application.exists())

      { contentType = Application.get().getMimeType(fileName); }

      if(contentType == null)

      { contentType = stream.getContentType(); }

      data.setContentType(contentType);

      This solutions offers the benefit, that the user can provide the correct mime type through the ResourceStream.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                junterstein Johannes Unterstein
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: