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

                 Key: WICKET-4421
                 URL: https://issues.apache.org/jira/browse/WICKET-4421
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.5.4
            Reporter: Johannes Unterstein


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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to