From 84167adb493503c9ec25fc42b72da4e8ba3f707b Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Mon, 23 Dec 2013 01:23:40 +0100 Subject: [PATCH] removed unused anomichttpd code after migration to jetty --- defaults/yacy.init | 3 - htroot/AccessTracker_p.java | 11 - htroot/Connections_p.java | 73 +- htroot/yacy/hello.java | 5 +- htroot/yacy/transferRWI.java | 5 +- htroot/yacy/transferURL.java | 4 +- .../yacy/http/Jetty8YaCySecurityHandler.java | 10 +- source/net/yacy/http/ProxyHandler.java | 4 +- source/net/yacy/http/YaCyDefaultServlet.java | 11 +- .../net/yacy/http/YaCyLegacyCredential.java | 3 +- source/net/yacy/http/YaCyProxyServlet.java | 365 ++-- source/net/yacy/http/YacyDomainHandler.java | 1 - .../yacy/interaction/AugmentHtmlStream.java | 157 -- .../yacy/server/http/AugmentedHtmlStream.java | 64 - .../yacy/server/http/HTTPDFileHandler.java | 1540 +---------------- .../yacy/server/http/HTTPDProxyHandler.java | 20 - source/net/yacy/server/http/HTTPDemon.java | 970 +---------- .../yacy/server/http/ServerSideIncludes.java | 99 -- source/net/yacy/server/serverCore.java | 1102 +----------- source/net/yacy/server/serverCoreSocket.java | 212 --- source/net/yacy/server/serverHandler.java | 105 -- source/net/yacy/server/serverSwitch.java | 38 - source/net/yacy/yacy.java | 20 +- 23 files changed, 214 insertions(+), 4608 deletions(-) delete mode 100644 source/net/yacy/interaction/AugmentHtmlStream.java delete mode 100644 source/net/yacy/server/http/AugmentedHtmlStream.java delete mode 100644 source/net/yacy/server/http/ServerSideIncludes.java delete mode 100644 source/net/yacy/server/serverCoreSocket.java delete mode 100644 source/net/yacy/server/serverHandler.java diff --git a/defaults/yacy.init b/defaults/yacy.init index f85c5f095..88ca29529 100644 --- a/defaults/yacy.init +++ b/defaults/yacy.init @@ -7,9 +7,6 @@ # you must delete the yacy.conf file in DATA/SETTINGS # ---------------------------------------------------------------------------- -# the HTTP service configurations -# choices are jetty or anomic -defaulthttpserver=jetty # port number where the server should bind to port = 8090 diff --git a/htroot/AccessTracker_p.java b/htroot/AccessTracker_p.java index cc477e615..75eea3e82 100644 --- a/htroot/AccessTracker_p.java +++ b/htroot/AccessTracker_p.java @@ -42,7 +42,6 @@ import net.yacy.peers.Seed; import net.yacy.search.Switchboard; import net.yacy.search.query.AccessTracker; import net.yacy.search.query.QueryParams; -import net.yacy.server.serverCore; import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; import net.yacy.server.serverAccessTracker.Track; @@ -93,16 +92,6 @@ public class AccessTracker_p { prop.put("page_num", entCount); entCount = 0; - try { - for (final Map.Entry bfe: serverCore.bfHost.entrySet()) { - prop.putHTML("page_bflist_" + entCount + "_host", bfe.getKey()); - prop.putNum("page_bflist_" + entCount + "_countSecond", bfe.getValue()); - entCount++; - } - } catch (final ConcurrentModificationException e) { - // we don't want to synchronize this - ConcurrentLog.logException(e); - } prop.put("page_bflist", entCount); } else if (page == 1) { String host = (post == null) ? "" : post.get("host", ""); diff --git a/htroot/Connections_p.java b/htroot/Connections_p.java index 6de5b625a..99804683a 100644 --- a/htroot/Connections_p.java +++ b/htroot/Connections_p.java @@ -27,9 +27,6 @@ //javac -classpath .:../classes Network.java //if the shell's current path is HTROOT -import java.io.UnsupportedEncodingException; -import java.net.InetAddress; -import java.net.URLEncoder; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -37,15 +34,10 @@ import java.util.Set; import net.yacy.cora.protocol.ConnectionInfo; import net.yacy.cora.protocol.RequestHeader; -import net.yacy.cora.util.ConcurrentLog; import net.yacy.http.YaCyHttpServer; -import net.yacy.peers.PeerActions; -import net.yacy.peers.Seed; import net.yacy.search.Switchboard; -import net.yacy.server.serverCore; import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; -import net.yacy.server.serverCore.Session; public final class Connections_p { @@ -64,7 +56,6 @@ public final class Connections_p { doNameLookup = post.getBoolean("nameLookup"); if (post.containsKey("closeServerSession")) { final String sessionName = post.get("closeServerSession", null); - sb.closeSessions(sessionName); prop.put(serverObjects.ACTION_LOCATION,""); return prop; } @@ -73,69 +64,7 @@ public final class Connections_p { } // waiting for all threads to finish - int idx = 0, numActiveRunning = 0, numActivePending = 0; - boolean dark = true; - for (final Session s: serverCore.getJobList()) { - if (!s.isAlive()) continue; - - // get the session runtime - final long sessionTime = s.getTime(); - - // get the request command line - String commandLine = s.getCommandLine(); - final boolean blockingRequest = (commandLine == null); - final int commandCount = s.getCommandCount(); - - // get the source ip address and port - final InetAddress userAddress = s.getUserAddress(); - final int userPort = s.getUserPort(); - if (userAddress == null) { - continue; - } - - String prot = "http"; // only httpd sessions listed - - // determining if the source is a yacy host - Seed seed = null; - if (doNameLookup) { - seed = sb.peers.lookupByIP(userAddress, -1, true, false, false); - if (seed != null && (seed.hash.equals(sb.peers.mySeed().hash)) && - (!seed.get(Seed.PORT,"").equals(Integer.toString(userPort)))) { - seed = null; - } - } - - prop.put("list_" + idx + "_dark", dark ? "1" : "0"); - dark = !dark; - try { - prop.put("list_" + idx + "_serverSessionID",URLEncoder.encode(s.getName(),"UTF8")); - } catch (final UnsupportedEncodingException e) { - // TODO Auto-generated catch block - ConcurrentLog.logException(e); - } - prop.putHTML("list_" + idx + "_sessionName", s.getName()); - prop.put("list_" + idx + "_proto", prot); - if (sessionTime > 1000*60) { - prop.put("list_" + idx + "_ms", "0"); - prop.put("list_" + idx + "_ms_duration",PeerActions.formatInterval(sessionTime)); - } else { - prop.put("list_" + idx + "_ms", "1"); - prop.putNum("list_" + idx + "_ms_duration", sessionTime); - } - prop.putHTML("list_" + idx + "_source",(seed!=null)?seed.getName()+".yacy":userAddress.getHostAddress()+":"+userPort); - prop.putHTML("list_" + idx + "_dest", "-"); - if (blockingRequest) { - prop.put("list_" + idx + "_running", "0"); - prop.putNum("list_" + idx + "_running_reqNr", commandCount+1); - numActivePending++; - } else { - prop.put("list_" + idx + "_running", "1"); - prop.put("list_" + idx + "_running_command", commandLine==null ? "" :commandLine); - numActiveRunning++; - } - prop.putNum("list_" + idx + "_used", commandCount); - idx++; - } + int idx = 0, numActivePending = 0; prop.put("list", idx); prop.putNum("numMax", httpd.getMaxSessionCount()); diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java index 17a1f1066..6a499572a 100644 --- a/htroot/yacy/hello.java +++ b/htroot/yacy/hello.java @@ -52,7 +52,7 @@ public final class hello { // example: // http://localhost:8090/yacy/hello.html?count=1&seed=p|{Hash=sCJ6Tq8T0N9x,Port=8090,PeerType=junior} // http://localhost:8090/yacy/hello.html?count=10&seed=z|H4sIAAAAAAAAADWQW2vDMAyF_81eJork3GyGX-YxGigly2WFvZTQijbQJsHx1pWx_z7nMj1J4ug7B_2s6-GsP5q3G-G6vBz2e0iz8t6zfuBr7-5PUNanQfulhqyzTkuUCFXvmitrBJtq4ed3tkPTtRpXhIiRDAmq0uhHFIiQMduJ-NXYU9NCbrrP1vnjIdUqgk09uIK51V6rMBRIilAo2NajwzfhGcx8QUKsEIp5iCJo-eaTVUXPfPQ4k5dm4pp8NzaESsLzS-14QVNIMlA-ka2m1JuZJJWIBRwPo0GIIiYp4zCSkC5GQSLiJIah0p6X_rvlS-MTbWdhkCSBIni9jA_rfP3-Ae1Oye9dAQAA - public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) throws InterruptedException { + public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { final Switchboard sb = (Switchboard) env; final serverObjects prop = new serverObjects(); final long start = System.currentTimeMillis(); @@ -146,7 +146,6 @@ public final class hello { !clientip.equals(reportedip) && clientversion >= yacyVersion.YACY_SUPPORTS_PORT_FORWARDING && magic != 0) { - serverCore.checkInterruption(); // try first the reportedip, since this may be a connect from a port-forwarding host prop.put("yourip", reportedip); @@ -171,7 +170,6 @@ public final class hello { } if (isNotLocal) { - serverCore.checkInterruption(); prop.put("yourip", clientip); remoteSeed.setIP(clientip); @@ -221,7 +219,6 @@ public final class hello { "' to '" + prop.get(Seed.YOURTYPE) + "'."); } - serverCore.checkInterruption(); final StringBuilder seeds = new StringBuilder(768); // attach some more seeds, as requested if (sb.peers.sizeConnected() > 0) { diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java index 03aa000f0..904cac4a8 100644 --- a/htroot/yacy/transferRWI.java +++ b/htroot/yacy/transferRWI.java @@ -53,13 +53,12 @@ import net.yacy.peers.Seed; import net.yacy.repository.Blacklist.BlacklistType; import net.yacy.search.Switchboard; import net.yacy.search.SwitchboardConstants; -import net.yacy.server.serverCore; import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; public final class transferRWI { - public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) throws InterruptedException { + public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { // return variable that accumulates replacements final Switchboard sb = (Switchboard) env; @@ -170,7 +169,6 @@ public final class transferRWI { int count = 0; Set testids = new HashSet(); while (it.hasNext()) { - serverCore.checkInterruption(); estring = it.next(); count++; if (count > 1000) break; // protection against flooding @@ -208,7 +206,6 @@ public final class transferRWI { } catch (final Exception e) { ConcurrentLog.logException(e); } - serverCore.checkInterruption(); // check if we need to ask for the corresponding URL testids.add(ASCII.String(urlHash)); diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.java index 746d42c3d..0fa03f33c 100644 --- a/htroot/yacy/transferURL.java +++ b/htroot/yacy/transferURL.java @@ -47,13 +47,12 @@ import net.yacy.peers.Seed; import net.yacy.repository.Blacklist.BlacklistType; import net.yacy.search.Switchboard; import net.yacy.search.SwitchboardConstants; -import net.yacy.server.serverCore; import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; public final class transferURL { - public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) throws InterruptedException { + public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) { final long start = System.currentTimeMillis(); long freshdate = 0; try {freshdate = GenericFormatter.SHORT_DAY_FORMATTER.parse("20061101").getTime();} catch (final ParseException e1) {} @@ -94,7 +93,6 @@ public final class transferURL { URIMetadataRow lEntry; Map lEm = new HashMap(); for (int i = 0; i < urlc; i++) { - serverCore.checkInterruption(); // read new lurl-entry urls = post.get("url" + i); diff --git a/source/net/yacy/http/Jetty8YaCySecurityHandler.java b/source/net/yacy/http/Jetty8YaCySecurityHandler.java index dc140a907..73d55a29b 100644 --- a/source/net/yacy/http/Jetty8YaCySecurityHandler.java +++ b/source/net/yacy/http/Jetty8YaCySecurityHandler.java @@ -26,13 +26,15 @@ package net.yacy.http; import java.io.IOException; import java.net.MalformedURLException; -import net.yacy.cora.document.id.MultiProtocolURL; +import javax.servlet.http.HttpServletResponse; + +import net.yacy.cora.document.id.MultiProtocolURL; import net.yacy.cora.protocol.Domains; import net.yacy.search.Switchboard; + import org.eclipse.jetty.http.HttpSchemes; import org.eclipse.jetty.security.RoleInfo; - import org.eclipse.jetty.security.SecurityHandler; import org.eclipse.jetty.security.UserDataConstraint; import org.eclipse.jetty.server.AbstractHttpConnection; @@ -86,7 +88,7 @@ public class Jetty8YaCySecurityHandler extends SecurityHandler { response.sendRedirect(url); } else - response.sendError(Response.SC_FORBIDDEN,"!Integral"); + response.sendError(HttpServletResponse.SC_FORBIDDEN,"!Integral"); request.setHandled(true); return false; @@ -109,7 +111,7 @@ public class Jetty8YaCySecurityHandler extends SecurityHandler { response.sendRedirect(url); } else - response.sendError(Response.SC_FORBIDDEN,"!Confidential"); + response.sendError(HttpServletResponse.SC_FORBIDDEN,"!Confidential"); request.setHandled(true); return false; diff --git a/source/net/yacy/http/ProxyHandler.java b/source/net/yacy/http/ProxyHandler.java index ed33dc19f..28abb168d 100644 --- a/source/net/yacy/http/ProxyHandler.java +++ b/source/net/yacy/http/ProxyHandler.java @@ -61,11 +61,9 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler { static RequestHeader convertHeaderFromJetty(HttpServletRequest request) { RequestHeader result = new RequestHeader(); - @SuppressWarnings("unchecked") Enumeration headerNames = request.getHeaderNames(); while(headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); - @SuppressWarnings("unchecked") Enumeration headers = request.getHeaders(headerName); while(headers.hasMoreElements()) { String header = headers.nextElement(); @@ -94,7 +92,7 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler { final String httpVer = request.getHeader(HeaderFramework.CONNECTION_PROP_HTTP_VER); setViaHeader (proxyHeaders, httpVer); proxyHeaders.remove(RequestHeader.KEEP_ALIVE); - proxyHeaders.remove(RequestHeader.CONTENT_LENGTH); + proxyHeaders.remove(HeaderFramework.CONTENT_LENGTH); final HTTPClient client = new HTTPClient(ClientIdentification.yacyProxyAgent); int timeout = 60000; diff --git a/source/net/yacy/http/YaCyDefaultServlet.java b/source/net/yacy/http/YaCyDefaultServlet.java index c3d59ad48..7403647a2 100644 --- a/source/net/yacy/http/YaCyDefaultServlet.java +++ b/source/net/yacy/http/YaCyDefaultServlet.java @@ -45,6 +45,7 @@ import javax.servlet.UnavailableException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import net.yacy.cora.date.GenericFormatter; import net.yacy.cora.document.analysis.Classification; import net.yacy.cora.protocol.HeaderFramework; @@ -65,13 +66,13 @@ import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; import net.yacy.server.servletProperties; import net.yacy.visualization.RasterPlotter; + import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItemFactory; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.eclipse.jetty.http.HttpHeaders; import org.eclipse.jetty.http.HttpMethods; - import org.eclipse.jetty.http.MimeTypes; import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.WriterOutputStream; @@ -470,7 +471,7 @@ public class YaCyDefaultServlet extends HttpServlet { HttpServletResponse response, boolean include, Resource resource, - Enumeration reqRanges) + Enumeration reqRanges) throws IOException { final long content_length = resource.length(); @@ -494,7 +495,7 @@ public class YaCyDefaultServlet extends HttpServlet { } } else { // Parse the satisfiable ranges - List ranges = InclusiveByteRange.satisfiableRanges(reqRanges, content_length); + List ranges = InclusiveByteRange.satisfiableRanges(reqRanges, content_length); // if there are no satisfiable ranges, send 416 response if (ranges == null || ranges.size() == 0) { @@ -727,7 +728,6 @@ public class YaCyDefaultServlet extends HttpServlet { if ((targetClass != null)) { serverObjects args = new serverObjects(); - @SuppressWarnings("unchecked") Enumeration argNames = request.getParameterNames(); while (argNames.hasMoreElements()) { String argName = argNames.nextElement(); @@ -735,7 +735,6 @@ public class YaCyDefaultServlet extends HttpServlet { } //TODO: for SSI request, local parameters are added as attributes, put them back as parameter for the legacy request // likely this should be implemented via httpservletrequestwrapper to supply complete parameters - @SuppressWarnings("unchecked") Enumeration attNames = request.getAttributeNames(); while (attNames.hasMoreElements()) { String argName = attNames.nextElement(); @@ -900,7 +899,7 @@ public class YaCyDefaultServlet extends HttpServlet { } // parse SSI line and include resource - protected void parseSSI(final net.yacy.cora.util.ByteBuffer in, final int off, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void parseSSI(final net.yacy.cora.util.ByteBuffer in, final int off, HttpServletRequest request, HttpServletResponse response) throws ServletException { if (in.startsWith(""), p + 10); - if (out instanceof ChunkedOutputStream) { - ((ChunkedOutputStream) out).write(in, off, p - off); - } else { - out.write(in.getBytes(off, p - off)); - } - parseSSI(in, p, out, authorization, requesthost, requestHeader); - off = q + 3; - p = in.indexOf(ASCII.getBytes("