if (contentType != null) {
contentType = contentType.toLowerCase();
for (String expected : SUPPORTED_MIME_TYPES) {
if (contentType.contains(expected)) {
// MIME type says its a supported image but we can't read it. Reject.
return new HttpResponseBuilder(original)
.setHttpStatusCode(HttpResponse.SC_UNSUPPORTED_MEDIA_TYPE)
.setResponseString(CONTENT_TYPE_AND_MIME_MISMATCH)
.create();
}
}
}
String path = uri.getPath().toLowerCase();
for (String supportedExtension : SUPPORTED_FILE_EXTENSIONS) {
if (path.endsWith(supportedExtension)) {
// The file extension says its a supported image but we can't read it. Reject.
return new HttpResponseBuilder(original)
.setHttpStatusCode(HttpResponse.SC_UNSUPPORTED_MEDIA_TYPE)
.setResponseString(CONTENT_TYPE_AND_EXTENSION_MISMATCH)
.create();
}
}