avoid erros from ConnectHandler, correction for #6d16fa9

pull/1/head
sixcooler 11 years ago
parent 97983ba89f
commit 10326892a8

@ -33,26 +33,28 @@ import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.repository.Blacklist.BlacklistType;
import net.yacy.search.Switchboard;
import org.eclipse.jetty.proxy.ConnectHandler;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
/**
* abstract jetty http handler
* only request to remote hosts (proxy requests) are processed by derived classes
*/
abstract public class AbstractRemoteHandler extends AbstractHandler implements Handler {
abstract public class AbstractRemoteHandler extends ConnectHandler implements Handler {
protected Switchboard sb = null;
private List<String> localVirtualHostNames; // list for quick check for req to local peer
@Override
protected void doStart() {
protected void doStart() throws Exception {
super.doStart();
sb = Switchboard.getSwitchboard();
localVirtualHostNames = new LinkedList<String>();
@ -130,6 +132,12 @@ abstract public class AbstractRemoteHandler extends AbstractHandler implements H
baseRequest.setHandled(true);
return;
}
if (request.getMethod().equalsIgnoreCase(HeaderFramework.METHOD_CONNECT)) {
// will be done by the ConnectHandler
super.handle(target, baseRequest, request, response);
return;
}
handleRemote(target, baseRequest, request, response);

@ -43,7 +43,6 @@ import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.utils.PKCS12Tool;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.proxy.ConnectHandler;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
@ -168,7 +167,7 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
// define list of YaCy specific general handlers
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]
{domainHandler, new ProxyCacheHandler(), new ProxyHandler(), new ConnectHandler()});
{domainHandler, new ProxyCacheHandler(), new ProxyHandler()});
// context handler for dispatcher and security (hint: dispatcher requires a context)
ContextHandler context = new ContextHandler();

@ -31,9 +31,11 @@ import java.io.OutputStream;
import java.net.SocketException;
import java.util.Date;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.document.id.DigestURL;
import net.yacy.cora.protocol.ClientIdentification;
@ -47,6 +49,7 @@ import net.yacy.crawler.data.Cache;
import net.yacy.crawler.retrieval.Response;
import net.yacy.server.http.HTTPDProxyHandler;
import net.yacy.server.http.MultiOutputStream;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.eclipse.jetty.server.Handler;
@ -61,7 +64,7 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler {
protected int timeout = 10000;
@Override
protected void doStart() {
protected void doStart() throws Exception {
super.doStart();
timeout = sb.getConfigInt("proxy.clientTimeout", 10000);
}
@ -141,11 +144,6 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler {
HttpServletResponse response) throws IOException, ServletException {
sb.proxyLastAccess = System.currentTimeMillis();
if (request.getMethod().equalsIgnoreCase(HeaderFramework.METHOD_CONNECT)) {
// will be done by the ConnectHandler
return;
}
RequestHeader proxyHeaders = convertHeaderFromJetty(request);
setProxyHeaderForClient(request, proxyHeaders);

Loading…
Cancel
Save