aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2012-12-18 07:09:21 (EST)
committerThomas Becker2012-12-18 07:09:21 (EST)
commit72cdab49349541f0a78a09ad8c765ba8bd9989f1 (patch)
treee1b6ae0f6cfd88028c213b0925bce1b6bc7c39de
parent58dff061e1bd6d1c7ab0ab0eea5c8762c472c2b0 (diff)
downloadorg.eclipse.jetty.project-72cdab49349541f0a78a09ad8c765ba8bd9989f1.zip
org.eclipse.jetty.project-72cdab49349541f0a78a09ad8c765ba8bd9989f1.tar.gz
org.eclipse.jetty.project-72cdab49349541f0a78a09ad8c765ba8bd9989f1.tar.bz2
395794 slightly modified fix for empty file extenstion to mime type mapping. Added a default, so it will also work with unknown file extensions
-rw-r--r--jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java2
-rw-r--r--jetty-http/src/main/resources/org/eclipse/jetty/http/mime.properties1
-rw-r--r--jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java15
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java2
4 files changed, 12 insertions, 8 deletions
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java b/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java
index 6e301f6..f1d6ca4 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java
@@ -237,7 +237,7 @@ public class MimeTypes
/** Set a mime mapping
* @param extension
* @param type
- */
+ */
public void addMimeMapping(String extension,String type)
{
_mimeMap.put(StringUtil.asciiToLowerCase(extension),normalizeMimeType(type));
diff --git a/jetty-http/src/main/resources/org/eclipse/jetty/http/mime.properties b/jetty-http/src/main/resources/org/eclipse/jetty/http/mime.properties
index 74601e3..52be400 100644
--- a/jetty-http/src/main/resources/org/eclipse/jetty/http/mime.properties
+++ b/jetty-http/src/main/resources/org/eclipse/jetty/http/mime.properties
@@ -1,3 +1,4 @@
+*=application/octet-stream
ai=application/postscript
aif=audio/x-aiff
aifc=audio/x-aiff
diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java
index 87073f0..069e123 100644
--- a/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java
+++ b/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java
@@ -18,11 +18,10 @@
package org.eclipse.jetty.http;
+import org.junit.Test;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import org.junit.Test;
public class MimeTypesTest
{
@@ -62,9 +61,13 @@ public class MimeTypesTest
@Test
public void testGetMimeByExtension_NoExtension()
{
- MimeTypes mimetypes = new MimeTypes();
- String contentType = mimetypes.getMimeByExtension("README");
- assertNull(contentType);
+ assertMimeTypeByExtension("application/octet-stream", "README");
+ }
+
+ @Test
+ public void testGetMimeByExtensionWithoutExistingMimeMapping()
+ {
+ assertMimeTypeByExtension("application/octet-stream", "awesome-font.ttf");
}
private void assertMimeTypeByExtension(String expectedMimeType, String filename)
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java
index 3f1f86e..48026ea 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java
@@ -383,7 +383,7 @@ public class ResourceCache
_resource=resource;
String mimeType = _mimeTypes.getMimeByExtension(_resource.toString());
- _contentType=(mimeType==null?null:BufferUtil.toBuffer(mimeType));
+ _contentType=BufferUtil.toBuffer(mimeType);
boolean exists=resource.exists();
_lastModified=exists?resource.lastModified():-1;
_lastModifiedBytes=_lastModified<0?null:BufferUtil.toBuffer(HttpFields.formatDate(_lastModified));