From 47a2a8885d274a635a51df2ca5ae3f1a7b27fa3c Mon Sep 17 00:00:00 2001 From: theli Date: Mon, 14 Nov 2005 12:05:57 +0000 Subject: [PATCH] *) Display MimeType on URL Info page git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1077 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ViewFile.html | 4 ++++ htroot/ViewFile.java | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/htroot/ViewFile.html b/htroot/ViewFile.html index 50285269a..e6db2b36f 100644 --- a/htroot/ViewFile.html +++ b/htroot/ViewFile.html @@ -33,6 +33,10 @@ #[size]# + MimeType + #[mimeType]# + + View as: Original | diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java index aaa32d5c8..5c01c6b73 100644 --- a/htroot/ViewFile.java +++ b/htroot/ViewFile.java @@ -51,9 +51,12 @@ import java.net.URLDecoder; import java.net.URLEncoder; import de.anomic.http.httpHeader; +import de.anomic.http.httpc; +import de.anomic.plasma.plasmaCrawlProfile; import de.anomic.plasma.plasmaParserDocument; import de.anomic.plasma.plasmaSwitchboard; import de.anomic.plasma.plasmaCrawlLURL.Entry; +import de.anomic.plasma.plasmaCrawlProfile.entry; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; @@ -78,6 +81,9 @@ public class ViewFile { serverObjects prop = new serverObjects(); plasmaSwitchboard sb = (plasmaSwitchboard)env; + + + if (post.containsKey("words")) try { prop.put("error_words",URLEncoder.encode((String) post.get("words"), "UTF-8")); @@ -115,6 +121,8 @@ public class ViewFile { // loading the resource content as byte array byte[] resource = null; + httpHeader resHeader = null; + String resMime = null; try { resource = sb.cacheManager.loadResource(url); if (resource == null) { @@ -127,6 +135,16 @@ public class ViewFile { return prop; } } + resHeader = sb.cacheManager.getCachedResponse(urlEntry.hash()); + if (resHeader == null) { + resHeader = httpc.whead(url,5000,null,null,sb.remoteProxyConfig); + if (resource == null) { + prop.put("error",4); + prop.put("viewMode",VIEW_MODE_NO_TEXT); + return prop; + } + resMime = resHeader.mime(); + } } catch (IOException e) { if (url == null) { prop.put("error",4); @@ -153,6 +171,7 @@ public class ViewFile { prop.put("viewMode",VIEW_MODE_NO_TEXT); return prop; } + resMime = document.getMimeType(); if (viewMode.equals("parsed")) { String content = new String(document.getText()); @@ -202,6 +221,7 @@ public class ViewFile { prop.put("error_wordCount",Integer.toString(urlEntry.wordCount())); prop.put("error_desc",urlEntry.descr()); prop.put("error_size",urlEntry.size()); + prop.put("error_mimeType",resMime); } return prop;