From 252bb51f98580e471753212b454d5f847c30233c Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Thu, 7 Mar 2013 15:31:00 +0100 Subject: [PATCH] fix for wrong mime type in noload crawler --- .../net/yacy/cora/document/analysis/Classification.java | 8 ++++---- source/net/yacy/crawler/retrieval/Response.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/net/yacy/cora/document/analysis/Classification.java b/source/net/yacy/cora/document/analysis/Classification.java index 6458f6cfd..0d32da96b 100644 --- a/source/net/yacy/cora/document/analysis/Classification.java +++ b/source/net/yacy/cora/document/analysis/Classification.java @@ -193,18 +193,18 @@ public class Classification { } 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) { - 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) { - return ext2mime(url.getFileExtension(), dfltMime); + return url == null ? "application/octet-stream" : ext2mime(url.getFileExtension(), dfltMime); } public static String url2mime(final MultiProtocolURI url) { - return ext2mime(url.getFileExtension()); + return url == null ? "application/octet-stream" : ext2mime(url.getFileExtension()); } } diff --git a/source/net/yacy/crawler/retrieval/Response.java b/source/net/yacy/crawler/retrieval/Response.java index 6c53c2be9..5230bbe2b 100644 --- a/source/net/yacy/crawler/retrieval/Response.java +++ b/source/net/yacy/crawler/retrieval/Response.java @@ -169,7 +169,7 @@ public class Response { // request and response headers may be zero in case that we process surrogates this.requestHeader = new RequestHeader(); 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())); this.profile = profile; this.status = QUEUE_STATE_FRESH;