diff --git a/jetty-server/src/main/config/etc/jetty-http.xml b/jetty-server/src/main/config/etc/jetty-http.xml index 1459ba8645a..8456a14d4ba 100644 --- a/jetty-server/src/main/config/etc/jetty-http.xml +++ b/jetty-server/src/main/config/etc/jetty-http.xml @@ -26,6 +26,10 @@ + diff --git a/jetty-server/src/main/config/etc/jetty-ssl.xml b/jetty-server/src/main/config/etc/jetty-ssl.xml index dcb8506d2a9..1fe331f2568 100644 --- a/jetty-server/src/main/config/etc/jetty-ssl.xml +++ b/jetty-server/src/main/config/etc/jetty-ssl.xml @@ -19,6 +19,10 @@ + diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyConnectionFactory.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyConnectionFactory.java index 78904f89de3..55baa87d1d0 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyConnectionFactory.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyConnectionFactory.java @@ -23,6 +23,7 @@ import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.nio.channels.ReadPendingException; import java.nio.channels.WritePendingException; +import java.util.Iterator; import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.Connection; @@ -44,17 +45,41 @@ public class ProxyConnectionFactory extends AbstractConnectionFactory { private static final Logger LOG = Log.getLogger(ProxyConnectionFactory.class); private final String _next; + + /* ------------------------------------------------------------ */ + /** Proxy Connection Factory that uses the next ConnectionFactory + * on the connector as the next protocol + */ + public ProxyConnectionFactory() + { + super("proxy"); + _next=null; + } public ProxyConnectionFactory(String nextProtocol) { - super("haproxy"); + super("proxy"); _next=nextProtocol; } - + @Override public Connection newConnection(Connector connector, EndPoint endp) { - return new ProxyConnection(endp,connector,_next); + String next=_next; + if (next==null) + { + for (Iterator i = connector.getProtocols().iterator();i.hasNext();) + { + String p=i.next(); + if (getProtocol().equalsIgnoreCase(p)) + { + next=i.next(); + break; + } + } + } + + return new ProxyConnection(endp,connector,next); } public static class ProxyConnection extends AbstractConnection diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ProxyConnectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ProxyConnectionTest.java index 1593372fdbd..98c860f45ff 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ProxyConnectionTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ProxyConnectionTest.java @@ -43,7 +43,7 @@ public class ProxyConnectionTest http.getHttpConfiguration().setRequestHeaderSize(1024); http.getHttpConfiguration().setResponseHeaderSize(1024); - ProxyConnectionFactory proxy = new ProxyConnectionFactory(http.getProtocol()); + ProxyConnectionFactory proxy = new ProxyConnectionFactory(); _connector = new LocalConnector(_server,null,null,null,1,proxy,http); _connector.setIdleTimeout(1000);