Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbiter committed Jan 5, 2014
1 parent 2939b47 commit 7005ecd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 79 deletions.
1 change: 0 additions & 1 deletion htroot/CrawlStartScanner_p.java
Expand Up @@ -42,7 +42,6 @@
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;
Expand Down
2 changes: 1 addition & 1 deletion source/net/yacy/http/CrashProtectionHandler.java
Expand Up @@ -36,7 +36,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
}
}

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();
Expand Down
6 changes: 3 additions & 3 deletions source/net/yacy/http/ProxyCacheHandler.java
Expand Up @@ -26,12 +26,12 @@

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;

Expand All @@ -46,7 +46,7 @@
*/
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<String, String> entry : cachedResponseHeader.entrySet()) {
Expand Down
74 changes: 0 additions & 74 deletions source/net/yacy/server/http/HTTPDemon.java
Expand Up @@ -401,65 +401,6 @@ else if (httpVersion.equals("HTTP/1.1") && HeaderFramework.http1_1.containsKey(I
}
}

private static final void sendRespondHeader(
final HashMap<String, Object> 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<String, Object> conProp,
final OutputStream respond,
Expand Down Expand Up @@ -568,21 +509,6 @@ else if (httpVersion.equals(HeaderFramework.HTTP_VERSION_1_1) && HeaderFramework
}
}

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
*/
Expand Down

0 comments on commit 7005ecd

Please sign in to comment.