8162745: content-types.properties files are missing some modern types
authorbpb
Mon, 08 Aug 2016 13:58:14 -0700
changeset 40208 4554a9ae19ef
parent 40207 cdd28dfda879
child 40209 68e8944f4424
8162745: content-types.properties files are missing some modern types Summary: Add some content types from HTML5 and Xiph. Reviewed-by: rriggs, chegar
jdk/src/java.base/unix/classes/sun/net/www/content-types.properties
jdk/src/java.base/windows/classes/sun/net/www/content-types.properties
jdk/test/java/nio/file/Files/probeContentType/Basic.java
--- a/jdk/src/java.base/unix/classes/sun/net/www/content-types.properties	Mon Aug 08 13:57:51 2016 -0700
+++ b/jdk/src/java.base/unix/classes/sun/net/www/content-types.properties	Mon Aug 08 13:58:14 2016 -0700
@@ -144,6 +144,10 @@
 	file_extensions=.ustar;\
 	action=save
 
+audio/aac: \
+	description=Advanced Audio Coding Audio;\
+	file_extensions=.aac
+
 audio/basic: \
 	description=Basic Audio;\
 	file_extensions=.snd,.au;\
@@ -151,6 +155,22 @@
 	action=application;\
 	application=audiotool %s
 
+audio/flac: \
+	description=Free Lossless Audio Codec Audio;\
+	file_extensions=.flac
+
+audio/mp4: \
+	description=MPEG-4 Audio;\
+	file_extensions=.m4a
+
+audio/mpeg: \
+	description=MPEG Audio;\
+	file_extensions=.mp2,.mp3
+
+audio/ogg: \
+	description=Ogg Audio;\
+	file_extensions=.oga,.ogg,.opus,.spx
+
 audio/x-aiff: \
 	description=Audio Interchange Format File;\
 	file_extensions=.aifc,.aif,.aiff;\
@@ -178,6 +198,10 @@
 	action=browser;\
 	application=imagetool %s
 
+image/svg+xml: \
+	description=Scalable Vector Graphics;\
+	file_extensions=.svg,.svgz
+
 image/tiff: \
 	description=TIFF Image;\
 	file_extensions=.tif,.tiff;\
@@ -248,6 +272,10 @@
 	description=Structure Enhanced Text;\
 	file_extensions=.etx
 
+video/mp4: \
+	description=MPEG-4 Video;\
+	file_extensions=.m4v,.mp4
+
 video/mpeg: \
 	description=MPEG Video Clip;\
 	file_extensions=.mpg,.mpe,.mpeg;\
@@ -255,10 +283,18 @@
 	action=application;\
 	application=mpeg_play %s
 
+video/ogg: \
+	description=Ogg Video;\
+	file_extensions=.ogv
+
 video/quicktime: \
 	description=QuickTime Video Clip;\
 	file_extensions=.mov,.qt
 
+video/webm: \
+	description=WebM Video;\
+	file_extensions=.webm
+
 application/x-troff-msvideo: \
 	description=AVI Video;\
 	file_extensions=.avi;\
--- a/jdk/src/java.base/windows/classes/sun/net/www/content-types.properties	Mon Aug 08 13:57:51 2016 -0700
+++ b/jdk/src/java.base/windows/classes/sun/net/www/content-types.properties	Mon Aug 08 13:58:14 2016 -0700
@@ -142,11 +142,31 @@
 	file_extensions=.ustar;\
 	action=save
 
+audio/aac: \
+	description=Advanced Audio Coding Audio;\
+	file_extensions=.aac
+
 audio/basic: \
 	description=Basic Audio;\
 	file_extensions=.snd,.au;\
 	icon=audio
 
+audio/flac: \
+	description=Free Lossless Audio Codec Audio;\
+	file_extensions=.flac
+
+audio/mp4: \
+	description=MPEG-4 Audio;\
+	file_extensions=.m4a
+
+audio/mpeg: \
+	description=MPEG Audio;\
+	file_extensions=.mp2,.mp3
+
+audio/ogg: \
+	description=Ogg Audio;\
+	file_extensions=.oga,.ogg,.opus,.spx
+
 audio/x-aiff: \
 	description=Audio Interchange Format File;\
 	file_extensions=.aifc,.aif,.aiff;\
@@ -175,6 +195,10 @@
 	icon=jpeg;\
 	action=browser
 
+image/svg+xml: \
+	description=Scalable Vector Graphics;\
+	file_extensions=.svg,.svgz
+
 image/tiff: \
 	description=TIFF Image;\
 	file_extensions=.tif,.tiff;\
@@ -245,15 +269,27 @@
 	description=Structure Enhanced Text;\
 	file_extensions=.etx
 
+video/mp4: \
+	description=MPEG-4 Video;\
+	file_extensions=.m4v,.mp4
+
 video/mpeg: \
 	description=MPEG Video Clip;\
 	file_extensions=.mpg,.mpe,.mpeg;\
 	icon=mpeg
 
+video/ogg: \
+	description=Ogg Video;\
+	file_extensions=.ogv
+
 video/quicktime: \
 	description=QuickTime Video Clip;\
 	file_extensions=.mov,.qt
 
+video/webm: \
+	description=WebM Video;\
+	file_extensions=.webm
+
 application/x-troff-msvideo: \
 	description=AVI Video;\
 	file_extensions=.avi;\
--- a/jdk/test/java/nio/file/Files/probeContentType/Basic.java	Mon Aug 08 13:57:51 2016 -0700
+++ b/jdk/test/java/nio/file/Files/probeContentType/Basic.java	Mon Aug 08 13:58:14 2016 -0700
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4313887 8129632 8129633 8162624 8146215
+ * @bug 4313887 8129632 8129633 8162624 8146215 8162745
  * @summary Unit test for probeContentType method
  * @library ../..
  * @build Basic SimpleFileTypeDetector
@@ -95,7 +95,7 @@
         return 0;
     }
 
-    static int checkOSXContentTypes(String[] extensions, String[] expectedTypes)
+    static int checkContentTypes(String[] extensions, String[] expectedTypes)
         throws IOException {
         if (extensions.length != expectedTypes.length) {
             System.err.println("Parameter array lengths differ");
@@ -157,18 +157,15 @@
             Files.delete(file);
         }
 
-        // Verify that common file extensions are mapped to the correct content
-        // types on Mac OS X only which has consistent Uniform Type Identifiers.
-        if (System.getProperty("os.name").contains("OS X")) {
-            String[] extensions = new String[]{
-                "jpg", "mp3", "mp4", "pdf", "png"
-            };
-            String[] expectedTypes = new String[]{
-                "image/jpeg", "audio/mpeg", "video/mp4", "application/pdf",
-                "image/png"
-            };
-            failures += checkOSXContentTypes(extensions, expectedTypes);
-        }
+        // Verify that certain media extensions are mapped to the correct type.
+        String[] extensions = new String[]{
+            "aac", "flac", "jpg", "mp3", "mp4", "pdf", "png", "webm"
+        };
+        String[] expectedTypes = new String[]{
+            "audio/aac", "audio/flac", "image/jpeg", "audio/mpeg",
+            "video/mp4", "application/pdf", "image/png", "video/webm"
+        };
+        failures += checkContentTypes(extensions, expectedTypes);
 
         if (failures > 0) {
             throw new RuntimeException("Test failed!");