395794 slightly modified fix for empty file extenstion to mime type mapping. Added a default, so it will also work with unknown file extensions
This commit is contained in:
parent
58dff061e1
commit
72cdab4934
|
@ -1,3 +1,4 @@
|
||||||
|
*=application/octet-stream
|
||||||
ai=application/postscript
|
ai=application/postscript
|
||||||
aif=audio/x-aiff
|
aif=audio/x-aiff
|
||||||
aifc=audio/x-aiff
|
aifc=audio/x-aiff
|
||||||
|
|
|
@ -18,11 +18,10 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.http;
|
package org.eclipse.jetty.http;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class MimeTypesTest
|
public class MimeTypesTest
|
||||||
{
|
{
|
||||||
|
@ -62,9 +61,13 @@ public class MimeTypesTest
|
||||||
@Test
|
@Test
|
||||||
public void testGetMimeByExtension_NoExtension()
|
public void testGetMimeByExtension_NoExtension()
|
||||||
{
|
{
|
||||||
MimeTypes mimetypes = new MimeTypes();
|
assertMimeTypeByExtension("application/octet-stream", "README");
|
||||||
String contentType = mimetypes.getMimeByExtension("README");
|
}
|
||||||
assertNull(contentType);
|
|
||||||
|
@Test
|
||||||
|
public void testGetMimeByExtensionWithoutExistingMimeMapping()
|
||||||
|
{
|
||||||
|
assertMimeTypeByExtension("application/octet-stream", "awesome-font.ttf");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertMimeTypeByExtension(String expectedMimeType, String filename)
|
private void assertMimeTypeByExtension(String expectedMimeType, String filename)
|
||||||
|
|
|
@ -383,7 +383,7 @@ public class ResourceCache
|
||||||
_resource=resource;
|
_resource=resource;
|
||||||
|
|
||||||
String mimeType = _mimeTypes.getMimeByExtension(_resource.toString());
|
String mimeType = _mimeTypes.getMimeByExtension(_resource.toString());
|
||||||
_contentType=(mimeType==null?null:BufferUtil.toBuffer(mimeType));
|
_contentType=BufferUtil.toBuffer(mimeType);
|
||||||
boolean exists=resource.exists();
|
boolean exists=resource.exists();
|
||||||
_lastModified=exists?resource.lastModified():-1;
|
_lastModified=exists?resource.lastModified():-1;
|
||||||
_lastModifiedBytes=_lastModified<0?null:BufferUtil.toBuffer(HttpFields.formatDate(_lastModified));
|
_lastModifiedBytes=_lastModified<0?null:BufferUtil.toBuffer(HttpFields.formatDate(_lastModified));
|
||||||
|
|
Loading…
Reference in New Issue