Return null from MockServletContext.getMimeType for unknown type

ServletContext.getMimeType() returns `null` for unknown mime types; not
`application/octet-stream`.

Issue: SPR-14908
This commit is contained in:
Arjen Poutsma
2017-03-23 12:45:48 +01:00
parent fd1db57e05
commit e2aa880301
3 changed files with 9 additions and 2 deletions

View File

@@ -50,6 +50,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.MediaTypeFactory;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.MimeType;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.util.WebUtils;
@@ -266,7 +267,9 @@ public class MockServletContext implements ServletContext {
return this.mimeTypes.get(extension).toString();
}
else {
return MediaTypeFactory.getMediaType(filePath).orElse(MediaType.APPLICATION_OCTET_STREAM).toString();
return MediaTypeFactory.getMediaType(filePath).
map(MimeType::toString)
.orElse(null);
}
}