diff --git a/source/net/yacy/http/Jetty8HttpServerImpl.java b/source/net/yacy/http/Jetty8HttpServerImpl.java index 46dad83a4..89e64a547 100644 --- a/source/net/yacy/http/Jetty8HttpServerImpl.java +++ b/source/net/yacy/http/Jetty8HttpServerImpl.java @@ -71,13 +71,6 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer { YacyDomainHandler domainHandler = new YacyDomainHandler(); domainHandler.setAlternativeResolver(sb.peers); - - /* this is now handled by YaCyDefaultServlet - ResourceHandler resource_handler = new ResourceHandler(); - resource_handler.setDirectoriesListed(true); - resource_handler.setWelcomeFiles(new String[]{"index.html"}); - resource_handler.setResourceBase("htroot/"); - */ //add SolrServlet ServletContextHandler solrContext = new ServletContextHandler(ServletContextHandler.SESSIONS); @@ -93,7 +86,6 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer { ServletHolder sholder = new ServletHolder(Jetty8YaCyDefaultServlet.class); sholder.setInitParameter("resourceBase", "htroot"); //sholder.setInitParameter("welcomeFile", "index.html"); // default is index.html, welcome.html - sholder.setInitParameter("gzip","false"); htrootContext.addServlet(sholder,"/*"); // add proxy?url= servlet @@ -104,15 +96,10 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer { ServletHolder gsaholder = new ServletHolder (GSAsearchServlet.class); htrootContext.addServlet(gsaholder,"/gsa/search"); - // assemble the servlet handlers - ContextHandlerCollection servletContext = new ContextHandlerCollection(); - servletContext.setHandlers(new Handler[] { solrContext, htrootContext }); - // define list of YaCy specific general handlers HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[] - {domainHandler, new ProxyCacheHandler(), new ProxyHandler() - /*, resource_handler, new DefaultHandler() */}); + {domainHandler, new ProxyCacheHandler(), new ProxyHandler()}); // context handler for dispatcher and security (hint: dispatcher requires a context) ContextHandler context = new ContextHandler(); @@ -123,7 +110,8 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer { // logic: 1. YaCy handlers are called if request not handled (e.g. proxy) then servlets handle it ContextHandlerCollection allrequesthandlers = new ContextHandlerCollection(); allrequesthandlers.addHandler(context); - allrequesthandlers.addHandler(servletContext); + allrequesthandlers.addHandler(solrContext); + allrequesthandlers.addHandler(htrootContext); allrequesthandlers.addHandler(new DefaultHandler()); // if not handled by other handler // wrap all handlers by security handler diff --git a/source/net/yacy/http/Jetty8YaCyDefaultServlet.java b/source/net/yacy/http/Jetty8YaCyDefaultServlet.java index 26ed6b74f..c3d62869a 100644 --- a/source/net/yacy/http/Jetty8YaCyDefaultServlet.java +++ b/source/net/yacy/http/Jetty8YaCyDefaultServlet.java @@ -39,7 +39,6 @@ import net.yacy.cora.util.ConcurrentLog; import net.yacy.kelondro.util.FileUtils; import org.eclipse.jetty.http.HttpContent; -import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeaders; import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.io.Buffer; @@ -77,9 +76,6 @@ import org.eclipse.jetty.util.resource.ResourceFactory; * * welcomeFile name of the welcome file (default is "index.html", "welcome.html") * - * gzip If set to true, then static content will be served as - * gzip content encoded if a matching resource is - * found ending with ".gz" * * resourceBase Set to replace the context resource base * @@ -108,8 +104,8 @@ public class Jetty8YaCyDefaultServlet extends YaCyDefaultServlet implements Reso @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String servletPath = null; - String pathInfo = null; + String servletPath; + String pathInfo; Enumeration reqRanges = null; boolean included = request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != null; if (included) { @@ -138,29 +134,8 @@ public class Jetty8YaCyDefaultServlet extends YaCyDefaultServlet implements Reso Resource resource = null; HttpContent content = null; try { - // is gzip enabled? - String pathInContextGz = null; - boolean gzip = false; - if (!included && _gzip && reqRanges == null && !endsWithSlash) { - // Look for a gzip resource - pathInContextGz = pathInContext + ".gz"; - resource = getResource(pathInContextGz); - - // Does a gzip resource exist? - if (resource != null && resource.exists() && !resource.isDirectory()) { - // Tell caches that response may vary by accept-encoding - response.addHeader(HttpHeaders.VARY, HeaderFramework.ACCEPT_ENCODING); - - // Does the client accept gzip? - String accept = request.getHeader(HeaderFramework.ACCEPT_ENCODING); - if (accept != null && accept.indexOf(HeaderFramework.CONTENT_ENCODING_GZIP) >= 0) { - gzip = true; - } - } - } - // find resource - if (!gzip) resource = getResource(pathInContext); + resource = getResource(pathInContext); // Look for a class resource boolean hasClass = false; @@ -204,13 +179,6 @@ public class Jetty8YaCyDefaultServlet extends YaCyDefaultServlet implements Reso handleTemplate(pathInfo, request, response); } else { if (included || passConditionalHeaders(request, response, resource, content)) { - if (gzip) { - response.setHeader(HeaderFramework.CONTENT_ENCODING, HeaderFramework.CONTENT_ENCODING_GZIP); - String mt = _servletContext.getMimeType(pathInContext); - if (mt != null) { - response.setContentType(mt); - } - } sendData(request, response, included, resource, content, reqRanges); } } @@ -412,9 +380,8 @@ public class Jetty8YaCyDefaultServlet extends YaCyDefaultServlet implements Reso content_length = content.getContentLength(); } - // Get the output stream (or writer) - OutputStream out = null; + OutputStream out; boolean written; try { out = response.getOutputStream(); diff --git a/source/net/yacy/http/YaCyDefaultServlet.java b/source/net/yacy/http/YaCyDefaultServlet.java index 4032c2601..41fe4f612 100644 --- a/source/net/yacy/http/YaCyDefaultServlet.java +++ b/source/net/yacy/http/YaCyDefaultServlet.java @@ -127,7 +127,7 @@ public abstract class YaCyDefaultServlet extends HttpServlet { protected boolean _dirAllowed = true; protected boolean _pathInfoOnly = false; protected boolean _etags = false; - protected boolean _gzip = true; + // protected boolean _gzip = true; protected Resource _resourceBase; protected MimeTypes _mimeTypes; protected String[] _welcomes; @@ -176,7 +176,7 @@ public abstract class YaCyDefaultServlet extends HttpServlet { } _etags = getInitBoolean("etags", _etags); - _gzip=getInitBoolean("gzip",_gzip); +// _gzip=getInitBoolean("gzip",_gzip); if (ConcurrentLog.isFine("FILEHANDLER")) { ConcurrentLog.fine("FILEHANDLER","YaCyDefaultServlet: resource base = " + _resourceBase); diff --git a/source/net/yacy/http/YaCyProxyServlet.java b/source/net/yacy/http/YaCyProxyServlet.java index 6e022552d..c6c710b33 100644 --- a/source/net/yacy/http/YaCyProxyServlet.java +++ b/source/net/yacy/http/YaCyProxyServlet.java @@ -191,16 +191,15 @@ public class YaCyProxyServlet extends ProxyServlet implements Servlet { final Pattern p = Pattern.compile("(href=\"|src=\")([^\"]+)|(href='|src=')([^']+)|(url\\(')([^']+)|(url\\(\")([^\"]+)|(url\\()([^\\)]+)"); final Matcher m = p.matcher(sbuffer); final StringBuffer result = new StringBuffer(80); - String init, url; Switchboard sb = Switchboard.getSwitchboard(); while (m.find()) { - init = null; + String init = null; if (m.group(1) != null) { init = m.group(1); } if (m.group(3) != null) { init = m.group(3); } if (m.group(5) != null) { init = m.group(5); } if (m.group(7) != null) { init = m.group(7); } if (m.group(9) != null) { init = m.group(9); } - url = null; + String url = null; if (m.group(2) != null) { url = m.group(2); } if (m.group(4) != null) { url = m.group(4); } if (m.group(6) != null) { url = m.group(6); } @@ -314,40 +313,16 @@ public class YaCyProxyServlet extends ProxyServlet implements Servlet { /** - * get a destination url from a querysting with parameter &url=_destinationurl_ - * - * @param querystring - * @return destinationURL - * @throws MalformedURLException + * get destination url (from query parameter &url=http://....) + * override to prevent calculating destination url from request + * + * @param request + * @param uri not used + * @return destination url from query parameter &url=_destinationurl_ + * @throws MalformedURLException */ - protected HttpURI proxyHttpURIfromQueryString(String querystring) throws MalformedURLException { - URL newurl = null; - String strARGS = querystring; - String action; - if (strARGS.startsWith("action=")) { - int detectnextargument = strARGS.indexOf("&"); - action = strARGS.substring(7, detectnextargument); - strARGS = strARGS.substring(detectnextargument + 1); - } - if (strARGS.startsWith("url=")) { - final String strUrl = strARGS.substring(4); // strip url= - - try { - newurl = new URL(strUrl); - } catch (final MalformedURLException e) { - - } - } - int port = newurl.getPort(); - if (port < 1) { - port = newurl.getDefaultPort(); - } - return proxyHttpURI(newurl.getProtocol(), newurl.getHost(), port, newurl.getPath()); - } - @Override protected HttpURI proxyHttpURI(HttpServletRequest request, String uri) throws MalformedURLException { - URL newurl = null; String strARGS = request.getQueryString(); if (strARGS.startsWith("action=")) { int detectnextargument = strARGS.indexOf("&"); @@ -357,16 +332,17 @@ public class YaCyProxyServlet extends ProxyServlet implements Servlet { final String strUrl = strARGS.substring(4); // strip url= try { - newurl = new URL(strUrl); + URL newurl = new URL(strUrl); + int port = newurl.getPort(); + if (port < 1) { + port = newurl.getDefaultPort(); + } + return proxyHttpURI(newurl.getProtocol(), newurl.getHost(), port, newurl.getPath()); } catch (final MalformedURLException e) { - + ConcurrentLog.fine("PROXY", "url parameter missing"); } } - int port = newurl.getPort(); - if (port < 1) { - port = newurl.getDefaultPort(); - } - return proxyHttpURI(newurl.getProtocol(), newurl.getHost(), port, newurl.getPath()); + return null; } @Override