fix for wrong mime type in noload crawler

pull/1/head
Michael Peter Christen 12 years ago
parent 25300913fa
commit 252bb51f98

@ -193,18 +193,18 @@ public class Classification {
} }
public static String ext2mime(final String ext) { public static String ext2mime(final String ext) {
return mimeTable.getProperty(ext, "application/" + (ext == null || ext.length() == 0 ? "octet-stream" : ext)); return ext == null ? "application/octet-stream" : mimeTable.getProperty(ext.toLowerCase(), "application/" + (ext == null || ext.length() == 0 ? "octet-stream" : ext));
} }
public static String ext2mime(final String ext, final String dfltMime) { public static String ext2mime(final String ext, final String dfltMime) {
return mimeTable.getProperty(ext, dfltMime); return ext == null ? "application/octet-stream" : mimeTable.getProperty(ext.toLowerCase(), dfltMime);
} }
public static String url2mime(final MultiProtocolURI url, final String dfltMime) { public static String url2mime(final MultiProtocolURI url, final String dfltMime) {
return ext2mime(url.getFileExtension(), dfltMime); return url == null ? "application/octet-stream" : ext2mime(url.getFileExtension(), dfltMime);
} }
public static String url2mime(final MultiProtocolURI url) { public static String url2mime(final MultiProtocolURI url) {
return ext2mime(url.getFileExtension()); return url == null ? "application/octet-stream" : ext2mime(url.getFileExtension());
} }
} }

@ -169,7 +169,7 @@ public class Response {
// request and response headers may be zero in case that we process surrogates // request and response headers may be zero in case that we process surrogates
this.requestHeader = new RequestHeader(); this.requestHeader = new RequestHeader();
this.responseHeader = new ResponseHeader(200); this.responseHeader = new ResponseHeader(200);
this.responseHeader.put(HeaderFramework.CONTENT_TYPE, "text/plain"); // tell parser how to handle the content this.responseHeader.put(HeaderFramework.CONTENT_TYPE, Classification.ext2mime(request.url().getFileExtension(), "text/plain")); // tell parser how to handle the content
if (!request.isEmpty()) this.responseHeader.put(HeaderFramework.CONTENT_LENGTH, Long.toString(request.size())); if (!request.isEmpty()) this.responseHeader.put(HeaderFramework.CONTENT_LENGTH, Long.toString(request.size()));
this.profile = profile; this.profile = profile;
this.status = QUEUE_STATE_FRESH; this.status = QUEUE_STATE_FRESH;

Loading…
Cancel
Save