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
|
@ -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));
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
*=application/octet-stream
|
||||
ai=application/postscript
|
||||
aif=audio/x-aiff
|
||||
aifc=audio/x-aiff
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue