diff --git a/htroot/Connections_p.java b/htroot/Connections_p.java index efcf017df..01b1b3a30 100644 --- a/htroot/Connections_p.java +++ b/htroot/Connections_p.java @@ -56,7 +56,7 @@ public final class Connections_p { // server sessions // get the serverCore thread - final WorkflowThread httpd = sb.getThread("10_httpd"); + //final WorkflowThread httpd = sb.getThread("10_httpd"); //not working with Jetty // determines if name lookup should be done or not final boolean doNameLookup; @@ -138,7 +138,7 @@ public final class Connections_p { } prop.put("list", idx); - prop.putNum("numMax", ((serverCore)httpd).getMaxSessionCount()); + prop.putNum("numMax", -1/* ((serverCore)httpd).getMaxSessionCount()*/); //TODO: get limit from Jetty prop.putNum("numActiveRunning", numActiveRunning); prop.putNum("numActivePending", numActivePending); diff --git a/source/net/yacy/http/HttpServer.java b/source/net/yacy/http/HttpServer.java index d8b2e3e24..7ac9df86c 100644 --- a/source/net/yacy/http/HttpServer.java +++ b/source/net/yacy/http/HttpServer.java @@ -40,46 +40,46 @@ import org.eclipse.jetty.server.nio.SelectChannelConnector; */ public class HttpServer { - private Server server = new Server(); - - /** - * @param port TCP Port to listen for http requests - */ - public HttpServer(int port) { - Switchboard sb = Switchboard.getSwitchboard(); - server = new Server(); + private Server server = new Server(); + + /** + * @param port TCP Port to listen for http requests + */ + public HttpServer(int port) { + Switchboard sb = Switchboard.getSwitchboard(); + SelectChannelConnector connector = new SelectChannelConnector(); connector.setPort(port); //connector.setThreadPool(new QueuedThreadPool(20)); server.addConnector(connector); - + YacyDomainHandler domainHandler = new YacyDomainHandler(); domainHandler.setAlternativeResolver(sb.peers); - + ResourceHandler resource_handler = new ResourceHandler(); resource_handler.setDirectoriesListed(true); - resource_handler.setWelcomeFiles(new String[]{ "index.html" }); - + resource_handler.setWelcomeFiles(new String[]{"index.html"}); + resource_handler.setResourceBase("htroot/"); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[] - { domainHandler, new ProxyCacheHandler(), new ProxyHandler(), new RewriteHandler(), - new SSIHandler(new TemplateHandler()), - resource_handler, new DefaultHandler() }); - + {domainHandler, new ProxyCacheHandler(), new ProxyHandler(), + new RewriteHandler(), new SSIHandler(new TemplateHandler()), + resource_handler, new DefaultHandler()}); + YaCySecurityHandler securityHandler = new YaCySecurityHandler(); securityHandler.setLoginService(new YaCyLoginService()); securityHandler.setRealmName("YaCy Admin Interface"); securityHandler.setHandler(new CrashProtectionHandler(handlers)); - + // context handler for dispatcher and security ContextHandler context = new ContextHandler(); context.setContextPath("/"); context.setHandler(securityHandler); - + server.setHandler(context); - } + } /** * start http server diff --git a/source/net/yacy/http/SSIHandler.java b/source/net/yacy/http/SSIHandler.java index 1db8a215f..314b747d0 100644 --- a/source/net/yacy/http/SSIHandler.java +++ b/source/net/yacy/http/SSIHandler.java @@ -84,7 +84,7 @@ public class SSIHandler extends ContentModHandler implements Handler, HandlerCon // //dispatcher.include(request, response); writeContent(path,request,response); - + response.flushBuffer(); } catch (Exception e) { ConcurrentLog.logException(e); @@ -102,7 +102,7 @@ public class SSIHandler extends ContentModHandler implements Handler, HandlerCon */ public void writeContent(final String path, HttpServletRequest request, HttpServletResponse response) { // check if there are arguments in path string - String args = ""; + String args; String fname = path; final int argpos = path.indexOf('?'); if (argpos > 0) { diff --git a/source/net/yacy/http/TemplateHandler.java b/source/net/yacy/http/TemplateHandler.java index d7567f033..a136784e5 100644 --- a/source/net/yacy/http/TemplateHandler.java +++ b/source/net/yacy/http/TemplateHandler.java @@ -82,24 +82,25 @@ import org.eclipse.jetty.server.handler.AbstractHandler; */ public class TemplateHandler extends AbstractHandler implements Handler { - private String htLocalePath = "DATA/LOCALE/htroot"; - private String htDefaultPath = "htroot"; - private String htDocsPath = "DATA/HTDOCS"; - - private static final serverClassLoader provider = new serverClassLoader(/*this.getClass().getClassLoader()*/); - + private String htLocalePath = "DATA/LOCALE/htroot"; + private String htDefaultPath = "htroot"; + private String htDocsPath = "DATA/HTDOCS"; + + private static final serverClassLoader provider = new serverClassLoader(/*this.getClass().getClassLoader()*/); + private ConcurrentHashMap> templateMethodCache = null; - @Override - protected void doStart() throws Exception { - super.doStart(); - templateMethodCache = new ConcurrentHashMap>(); - } + @Override + protected void doStart() throws Exception { + super.doStart(); + templateMethodCache = new ConcurrentHashMap>(); + htDocsPath = Switchboard.getSwitchboard().htDocsPath.getPath(); + } - @Override - protected void doStop() throws Exception { - super.doStop(); - } + @Override + protected void doStop() throws Exception { + super.doStop(); + } /** Returns a path to the localized or default file according to the parameter localeSelection * @param path relative from htroot @@ -228,16 +229,13 @@ public class TemplateHandler extends AbstractHandler implements Handler { try { tmp = invokeServlet(targetClass, legacyRequestHeader, args); } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + ConcurrentLog.logException(e); throw new ServletException(); } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + ConcurrentLog.logException(e); throw new ServletException(); } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + ConcurrentLog.logException(e); throw new ServletException(); } @@ -245,15 +243,15 @@ public class TemplateHandler extends AbstractHandler implements Handler { ByteBuffer result = null; - if (tmp instanceof RasterPlotter) { - final RasterPlotter yp = (RasterPlotter) tmp; - // send an image to client - result = RasterPlotter.exportImage(yp.getImage(), "png"); - } - if (tmp instanceof EncodedImage) { - final EncodedImage yp = (EncodedImage) tmp; - result = yp.getImage(); - } + if (tmp instanceof RasterPlotter) { + final RasterPlotter yp = (RasterPlotter) tmp; + // send an image to client + result = RasterPlotter.exportImage(yp.getImage(), "png"); + } + if (tmp instanceof EncodedImage) { + final EncodedImage yp = (EncodedImage) tmp; + result = yp.getImage(); + } if (tmp instanceof Image) { final Image i = (Image) tmp;