From dd98b88732e8d6ff0a5fd5de38cd16f2dd31d641 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 23 Aug 2022 16:38:31 -0700 Subject: [PATCH] Fix 'Align MimeMappings with Tomcat's defaults' Update COMMON_MAPPINGS to align with the properties file and change the test so that it consistently works. See gh-32101 --- .../org/springframework/boot/web/server/MimeMappings.java | 4 ++-- .../springframework/boot/web/server/MimeMappingsTests.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java index b731532830..077348af41 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java @@ -261,14 +261,14 @@ public sealed class MimeMappings implements Iterable { mappings.add("jpg", "image/jpeg"); mappings.add("js", "application/javascript"); mappings.add("json", "application/json"); - mappings.add("otf", "application/x-font-opentype"); + mappings.add("otf", "font/otf"); mappings.add("pdf", "application/pdf"); mappings.add("png", "image/png"); mappings.add("ps", "application/postscript"); mappings.add("tar", "application/x-tar"); mappings.add("tif", "image/tiff"); mappings.add("tiff", "image/tiff"); - mappings.add("ttf", "application/x-font-ttf"); + mappings.add("ttf", "font/ttf"); mappings.add("txt", "text/plain"); mappings.add("xht", "application/xhtml+xml"); mappings.add("xhtml", "application/xhtml+xml"); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/server/MimeMappingsTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/server/MimeMappingsTests.java index 0d84f76e80..60e4882693 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/server/MimeMappingsTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/server/MimeMappingsTests.java @@ -174,9 +174,11 @@ class MimeMappingsTests { @Test void commonMappingsAreSubsetOfAllMappings() { + MimeMappings defaultMappings = new DefaultMimeMappings(); MimeMappings commonMappings = (MimeMappings) ReflectionTestUtils.getField(DefaultMimeMappings.class, "COMMON"); + defaultMappings.getAll(); for (Mapping commonMapping : commonMappings) { - assertThat(MimeMappings.DEFAULT.get(commonMapping.getExtension())).isEqualTo(commonMapping.getMimeType()); + assertThat(defaultMappings.get(commonMapping.getExtension())).isEqualTo(commonMapping.getMimeType()); } }