vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

MimeMapping.getMimeTypeForExtension should be Case Insensitive

Open leotu opened this issue 3 years ago • 0 comments

Issue

Static file response no content type if extension name contains upper case characters

StaticHandlerImpl.java#L463

Version

4.2.7

Do you have a reproducer?

MimeMapping.java#L1016

Steps to reproduce

@TestMethodOrder(OrderAnnotation.class)
public class MimeMappingTester {

    @Test
    @Order(1)
    void textLocalFile() {
        Path file = Path.of("/Users/leo/Pictures/IMG_4157.JPG");
        System.out.println(String.format("'%s', contentType: %s", file, MimeMapping.getMimeTypeForFilename(file.toString())));

        Path file2 = Path.of("/Users/leo/Pictures/IMG_4157.jpg");
        System.out.println(String.format("'%s', contentType: %s", file2, MimeMapping.getMimeTypeForFilename(file2.toString())));
    }

    @Test
    @Order(2)
    void textUrlFile() {
        try {
            URL url = new URL("https://xgos.com/Pictures/IMG_4157.JPG");
            System.out.println(String.format("'%s', contentType: %s", url, MimeMapping.getMimeTypeForFilename(url.toString())));

            URL url2 = new URL("https://xgos.com/Pictures/IMG_4157.jpg");
            System.out.println(String.format("'%s', contentType: %s", url2, MimeMapping.getMimeTypeForFilename(url2.toString())));
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }
}

Console Output

'/Users/leo/Pictures/IMG_4157.JPG', contentType: null
'/Users/leo/Pictures/IMG_4157.jpg', contentType: image/jpeg

'https://xgos.com/Pictures/IMG_4157.JPG', contentType: null
'https://xgos.com/Pictures/IMG_4157.jpg', contentType: image/jpeg

leotu avatar Oct 02 '22 05:10 leotu