From 7005ecdabd7b9df325f6c6999e488c0f3abcacf3 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Sun, 5 Jan 2014 15:06:40 +0100 Subject: [PATCH] cleanup --- htroot/CrawlStartScanner_p.java | 1 - .../net/yacy/http/CrashProtectionHandler.java | 2 +- source/net/yacy/http/ProxyCacheHandler.java | 6 +- source/net/yacy/server/http/HTTPDemon.java | 74 ------------------- 4 files changed, 4 insertions(+), 79 deletions(-) diff --git a/htroot/CrawlStartScanner_p.java b/htroot/CrawlStartScanner_p.java index b02027ff0..190f023c4 100644 --- a/htroot/CrawlStartScanner_p.java +++ b/htroot/CrawlStartScanner_p.java @@ -42,7 +42,6 @@ import net.yacy.cora.sorting.ReversibleScoreMap; import net.yacy.cora.util.ConcurrentLog; import net.yacy.data.WorkTables; import net.yacy.search.Switchboard; -import net.yacy.search.SwitchboardConstants; import net.yacy.search.query.SearchEventCache; import net.yacy.search.schema.CollectionSchema; import net.yacy.server.serverObjects; diff --git a/source/net/yacy/http/CrashProtectionHandler.java b/source/net/yacy/http/CrashProtectionHandler.java index d85692dae..4b143fa89 100644 --- a/source/net/yacy/http/CrashProtectionHandler.java +++ b/source/net/yacy/http/CrashProtectionHandler.java @@ -36,7 +36,7 @@ public class CrashProtectionHandler extends HandlerWrapper implements Handler, H } } - private void writeResponse(HttpServletRequest request, HttpServletResponse response, Exception exc) throws IOException { + private void writeResponse(@SuppressWarnings("unused") HttpServletRequest request, HttpServletResponse response, Exception exc) throws IOException { PrintWriter out; try { // prevent exception after partial response (only getWriter not allowed if getOutputStream called before; Servlet API 3.0 ) out = response.getWriter(); diff --git a/source/net/yacy/http/ProxyCacheHandler.java b/source/net/yacy/http/ProxyCacheHandler.java index 08f985531..4a303effc 100644 --- a/source/net/yacy/http/ProxyCacheHandler.java +++ b/source/net/yacy/http/ProxyCacheHandler.java @@ -26,12 +26,12 @@ package net.yacy.http; import java.io.IOException; import java.util.Map.Entry; -import javax.servlet.ServletException; +import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import net.yacy.cora.document.id.DigestURL; +import net.yacy.cora.document.id.DigestURL; import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.protocol.ResponseHeader; @@ -46,7 +46,7 @@ import net.yacy.crawler.retrieval.Response; */ public class ProxyCacheHandler extends AbstractRemoteHandler implements Handler { - private void handleRequestFromCache(HttpServletRequest request, HttpServletResponse response, ResponseHeader cachedResponseHeader, byte[] content) throws IOException { + private void handleRequestFromCache(@SuppressWarnings("unused") HttpServletRequest request, HttpServletResponse response, ResponseHeader cachedResponseHeader, byte[] content) throws IOException { // TODO: check if-modified for (Entry entry : cachedResponseHeader.entrySet()) { diff --git a/source/net/yacy/server/http/HTTPDemon.java b/source/net/yacy/server/http/HTTPDemon.java index 368ec6d9e..ba6ce44a0 100644 --- a/source/net/yacy/server/http/HTTPDemon.java +++ b/source/net/yacy/server/http/HTTPDemon.java @@ -401,65 +401,6 @@ public final class HTTPDemon { } } - private static final void sendRespondHeader( - final HashMap conProp, - final OutputStream respond, - final String httpVersion, - final int httpStatusCode, - final String httpStatusText, - String contentType, - final long contentLength, - Date moddate, - final Date expires, - ResponseHeader headers, - final String contentEnc, - final String transferEnc, - final boolean nocache - ) throws IOException { - - final String reqMethod = (String) conProp.get(HeaderFramework.CONNECTION_PROP_METHOD); - - if ((transferEnc != null) && !httpVersion.equals(HeaderFramework.HTTP_VERSION_1_1)) { - throw new IllegalArgumentException("Transfer encoding is only supported for http/1.1 connections. The current connection version is " + httpVersion); - } - - if (!reqMethod.equals(HeaderFramework.METHOD_HEAD)){ - if (!"close".equals(conProp.get(HeaderFramework.CONNECTION_PROP_PERSISTENT)) && - transferEnc == null && contentLength < 0) { - throw new IllegalArgumentException("Message MUST contain a Content-Length or a non-identity transfer-coding header field."); - } - if (transferEnc != null && contentLength >= 0) { - throw new IllegalArgumentException("Messages MUST NOT include both a Content-Length header field and a non-identity transfer-coding."); - } - } - - if (headers == null) headers = new ResponseHeader(httpStatusCode); - final Date now = new Date(System.currentTimeMillis()); - - headers.put(HeaderFramework.SERVER, "AnomicHTTPD (www.anomic.de)"); - headers.put(HeaderFramework.DATE, HeaderFramework.formatRFC1123(now)); - if (moddate.after(now)) { - moddate = now; - } - headers.put(HeaderFramework.LAST_MODIFIED, HeaderFramework.formatRFC1123(moddate)); - - if (nocache) { - headers.put(HeaderFramework.CACHE_CONTROL, "no-cache"); - headers.put(HeaderFramework.CACHE_CONTROL, "no-store"); - headers.put(HeaderFramework.PRAGMA, "no-cache"); - } - - if (contentType == null) contentType = "text/html; charset=UTF-8"; - if (headers.get(HeaderFramework.CONTENT_TYPE) == null) headers.put(HeaderFramework.CONTENT_TYPE, contentType); - if (contentLength > 0) headers.put(HeaderFramework.CONTENT_LENGTH, Long.toString(contentLength)); - //if (cookie != null) headers.put(httpHeader.SET_COOKIE, cookie); - if (expires != null) headers.put(HeaderFramework.EXPIRES, HeaderFramework.formatRFC1123(expires)); - if (contentEnc != null) headers.put(HeaderFramework.CONTENT_ENCODING, contentEnc); - if (transferEnc != null) headers.put(HeaderFramework.TRANSFER_ENCODING, transferEnc); - - sendRespondHeader(conProp, respond, httpVersion, httpStatusCode, httpStatusText, headers); - } - static final void sendRespondHeader( final HashMap conProp, final OutputStream respond, @@ -568,21 +509,6 @@ public final class HTTPDemon { } } - private static boolean isThisSeedIP(final String hostName) { - if ((hostName == null) || (hostName.isEmpty())) return false; - - // getting ip address and port of this seed - if (getAlternativeResolver() == null) return false; - - // resolve ip addresses - final InetAddress seedInetAddress = Domains.dnsResolve(getAlternativeResolver().myIP()); - final InetAddress hostInetAddress = Domains.dnsResolve(hostName); - if (seedInetAddress == null || hostInetAddress == null) return false; - - // if it's equal, the hostname points to this seed - return (seedInetAddress.equals(hostInetAddress)); - } - /** * @param alternativeResolver the alternativeResolver to set */