From 3b18490eada15f896c67a287f1d9a495a0465b6d Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 25 Jul 2013 16:08:02 +0200 Subject: [PATCH 1/6] 409028 - Jetty HttpClient does not work with proxy CONNECT method. The problem was due to the fact that the server replied with HTTP/1.0 to the CONNECT request; because of this, the parser was set as non persistent, and the tunnel was immediately closed. Now we are setting the parser as persistent if the method is a CONNECT, no matter what HTTP version the server specifies. --- .../jetty/client/AbstractHttpConnection.java | 7 ++- .../jetty/client/ProxyTunnellingTest.java | 60 +++++++++++++++++-- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java index 12560b3d1b2..916f082e0ff 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java @@ -36,7 +36,6 @@ import org.eclipse.jetty.http.HttpVersions; import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffers; -import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; @@ -318,7 +317,11 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen { HttpExchange exchange = _exchange; if (exchange!=null) + { exchange.setStatus(HttpExchange.STATUS_PARSING_CONTENT); + if (HttpMethods.CONNECT.equalsIgnoreCase(exchange.getMethod())) + _parser.setPersistent(true); + } } @Override @@ -350,8 +353,6 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen } } } - - } @Override diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java index 550c5418ea0..c887d1fb2fa 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java @@ -20,6 +20,7 @@ package org.eclipse.jetty.client; import java.io.IOException; import java.io.InterruptedIOException; +import java.net.Socket; import java.net.URLEncoder; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -46,6 +47,7 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.After; import org.junit.Assert; +import org.junit.Assume; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -106,14 +108,20 @@ public class ProxyTunnellingTest protected void stopServer() throws Exception { - server.stop(); - server.join(); + if (server != null) + { + server.stop(); + server.join(); + } } protected void stopProxy() throws Exception { - proxy.stop(); - proxy.join(); + if (proxy != null) + { + proxy.stop(); + proxy.join(); + } } @Test @@ -337,6 +345,50 @@ public class ProxyTunnellingTest } } + @Test + public void testExternalProxy() throws Exception + { + // Free proxy server obtained from http://hidemyass.com/proxy-list/ + String proxyHost = "81.208.25.53"; + int proxyPort = 3128; + try + { + new Socket(proxyHost, proxyPort).close(); + } + catch (IOException x) + { + Assume.assumeNoException(x); + } + + // Start the server to start the SslContextFactory + startSSLServer(new AbstractHandler() + { + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException + { + throw new ServletException(); + } + }); + + HttpClient httpClient = new HttpClient(); + httpClient.setProxy(new Address(proxyHost, proxyPort)); + httpClient.registerListener(RedirectListener.class.getName()); + httpClient.start(); + + try + { + ContentExchange exchange = new ContentExchange(true); + exchange.setTimeout(5000); + exchange.setURL("https://www.google.com"); + httpClient.send(exchange); + assertEquals(HttpExchange.STATUS_COMPLETED, exchange.waitForDone()); + assertEquals(200, exchange.getResponseStatus()); + } + finally + { + httpClient.stop(); + } + } + private static class ServerHandler extends AbstractHandler { public void handle(String target, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException From 06504f2c65be428667cd6bcd73f9500736702957 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 25 Jul 2013 17:20:17 +0200 Subject: [PATCH 2/6] Fixed proxy test. --- .../jetty/client/ProxyFakeTunnelTest.java | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java index 236a6b7ff10..eaed5251167 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyFakeTunnelTest.java @@ -36,12 +36,12 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest { return _proxySocket.getLocalPort(); } - + protected void startProxy() throws Exception { _proxySocket = new ServerSocket(0); - + _proxyThread = new Thread() { @Override @@ -63,19 +63,28 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest }; _proxyThread.setDaemon(true); _proxyThread.start(); - + } protected void stopProxy() throws Exception { - _proxySocket.close(); - _proxyThread.interrupt(); + if (_proxySocket != null) + { + _proxySocket.close(); + _proxyThread.interrupt(); + } + } + + @Override + public void testExternalProxy() throws Exception + { + // Do not execute this test, since it won't hit the fake proxy } static class FakeProxy extends Thread { Socket _socket; - + public FakeProxy(Socket socket) { _socket=socket; @@ -86,50 +95,50 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest Socket toserver=null; final InputStream in; - final OutputStream out; + final OutputStream out; try { in = _socket.getInputStream(); out = _socket.getOutputStream(); - + String address=""; int state=0; - + for (int b=in.read();b>=0;b=in.read()) - { + { switch(state) { case 0: if (' '==b) state=1; break; - + case 1: if (' '==b) state=2; else address+=(char)b; break; - + case 2: if ('\r'==b) state=3; break; - + case 3: if ('\n'==b) state=4; else state=2; break; - + case 4: if ('\r'==b) state=5; else state=2; break; - + case 5: if ('\n'==b) { @@ -142,7 +151,7 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest out.write(( "HTTP/1.1 200 OK\r\n"+ "Server: fake\r\n"+ - // "Content-Length: 0\r\n"+ + // "Content-Length: 0\r\n"+ "\r\n" ).getBytes()); } @@ -151,12 +160,12 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest out.write(( "HTTP/1.1 503 Unavailable\r\n"+ "Server: fake\r\n"+ - "Content-Length: 0\r\n"+ + "Content-Length: 0\r\n"+ "\r\n" ).getBytes()); } out.flush(); - + if (toserver!=null) { final InputStream from = toserver.getInputStream(); @@ -188,7 +197,7 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest copy.setDaemon(true); copy.start(); } - + } else state=2; @@ -196,11 +205,11 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest case 6: toserver.getOutputStream().write((byte)b); - + } } - - + + } catch (IOException e) { @@ -221,8 +230,8 @@ public class ProxyFakeTunnelTest extends ProxyTunnellingTest } } } - + } - - + + } From eed3a7fec05b8722f7baec62d272f4f56d56cd1f Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 25 Jul 2013 17:36:41 +0200 Subject: [PATCH 3/6] Increase external proxy test timeout. --- .../java/org/eclipse/jetty/client/ProxyTunnellingTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java index c887d1fb2fa..fd4c1a2d350 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ProxyTunnellingTest.java @@ -377,7 +377,8 @@ public class ProxyTunnellingTest try { ContentExchange exchange = new ContentExchange(true); - exchange.setTimeout(5000); + // Use a longer timeout, sometimes the proxy takes a while to answer + exchange.setTimeout(20000); exchange.setURL("https://www.google.com"); httpClient.send(exchange); assertEquals(HttpExchange.STATUS_COMPLETED, exchange.waitForDone()); From c76de0b584a4bfb7512e435b531063a4994a992a Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 26 Jul 2013 11:40:12 +1000 Subject: [PATCH 4/6] 404468 Ported jetty-http-spi to Jetty-9 --- jetty-http-spi/pom.xml | 2 +- .../jetty/http/spi/DelegatingThreadPool.java | 142 ++++++++++++++++++ .../jetty/http/spi/JettyHttpServer.java | 34 +++-- .../http/spi/JettyHttpServerProvider.java | 14 +- .../http/spi/ThreadPoolExecutorAdapter.java | 124 --------------- .../eclipse/jetty/server/ServerConnector.java | 17 +++ pom.xml | 2 +- 7 files changed, 191 insertions(+), 144 deletions(-) create mode 100644 jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java delete mode 100644 jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/ThreadPoolExecutorAdapter.java diff --git a/jetty-http-spi/pom.xml b/jetty-http-spi/pom.xml index 42439750c09..263c91fcc12 100644 --- a/jetty-http-spi/pom.xml +++ b/jetty-http-spi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.0.0-SNAPSHOT + 9.0.5-SNAPSHOT 4.0.0 jetty-http-spi diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java new file mode 100644 index 00000000000..245ca1db341 --- /dev/null +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java @@ -0,0 +1,142 @@ +package org.eclipse.jetty.http.spi; + +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.eclipse.jetty.util.component.ContainerLifeCycle; +import org.eclipse.jetty.util.component.LifeCycle; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.util.thread.ThreadPool; + +public class DelegatingThreadPool extends ContainerLifeCycle implements ThreadPool +{ + private static final Logger LOG = Log.getLogger(DelegatingThreadPool.class); + + private Executor _executor; // memory barrier provided by start/stop semantics + + public DelegatingThreadPool(Executor executor) + { + _executor=executor; + addBean(_executor); + } + + /* ------------------------------------------------------------ */ + public Executor getExecutor() + { + return _executor; + } + + /* ------------------------------------------------------------ */ + public void setExecutor(Executor executor) + { + if (isRunning()) + throw new IllegalStateException(getState()); + updateBean(_executor,executor); + _executor=executor; + } + + /* ------------------------------------------------------------ */ + @Override + public void execute(Runnable job) + { + _executor.execute(job); + } + + + /* ------------------------------------------------------------ */ + @Override + public boolean dispatch(Runnable job) + { + final Executor executor=_executor; + if (executor instanceof ThreadPool) + return ((ThreadPool)executor).dispatch(job); + + try + { + _executor.execute(job); + return true; + } + catch(RejectedExecutionException e) + { + LOG.warn(e); + return false; + } + } + + /* ------------------------------------------------------------ */ + @Override + public int getIdleThreads() + { + final Executor executor=_executor; + if (executor instanceof ThreadPool) + return ((ThreadPool)executor).getIdleThreads(); + + if (executor instanceof ThreadPoolExecutor) + { + final ThreadPoolExecutor tpe = (ThreadPoolExecutor)executor; + return tpe.getPoolSize() - tpe.getActiveCount(); + } + return -1; + } + + /* ------------------------------------------------------------ */ + @Override + public int getThreads() + { + final Executor executor=_executor; + if (executor instanceof ThreadPool) + return ((ThreadPool)executor).getThreads(); + + if (executor instanceof ThreadPoolExecutor) + { + final ThreadPoolExecutor tpe = (ThreadPoolExecutor)executor; + return tpe.getPoolSize(); + } + return -1; + } + + /* ------------------------------------------------------------ */ + @Override + public boolean isLowOnThreads() + { + final Executor executor=_executor; + if (executor instanceof ThreadPool) + return ((ThreadPool)executor).isLowOnThreads(); + + if (executor instanceof ThreadPoolExecutor) + { + final ThreadPoolExecutor tpe = (ThreadPoolExecutor)executor; + // getActiveCount() locks the thread pool, so execute it last + return tpe.getPoolSize() == tpe.getMaximumPoolSize() && + tpe.getQueue().size() >= tpe.getPoolSize() - tpe.getActiveCount(); + } + return false; + } + + /* ------------------------------------------------------------ */ + @Override + public void join() throws InterruptedException + { + final Executor executor=_executor; + if (executor instanceof ThreadPool) + ((ThreadPool)executor).join(); + else if (executor instanceof ExecutorService) + ((ExecutorService)executor).awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); + else + throw new IllegalStateException(); + } + + /* ------------------------------------------------------------ */ + @Override + protected void doStop() throws Exception + { + super.doStop(); + if (!(_executor instanceof LifeCycle) && (_executor instanceof ExecutorService)) + ((ExecutorService)_executor).shutdownNow(); + } + +} diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java index f5af9720d5e..22e6b3d576c 100644 --- a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java @@ -20,18 +20,26 @@ package org.eclipse.jetty.http.spi; import com.sun.net.httpserver.HttpContext; import com.sun.net.httpserver.HttpHandler; + import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Handler; +import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.ContextHandlerCollection; -import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; + + + +import org.eclipse.jetty.util.thread.ThreadPool; + import java.io.IOException; import java.net.InetSocketAddress; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executor; @@ -68,10 +76,10 @@ public class JettyHttpServer extends com.sun.net.httpserver.HttpServer public void bind(InetSocketAddress addr, int backlog) throws IOException { // check if there is already a connector listening - Connector[] connectors = _server.getConnectors(); + Collection connectors = _server.getBeans(NetworkConnector.class); if (connectors != null) { - for (Connector connector : connectors) + for (NetworkConnector connector : connectors) { if (connector.getPort() == addr.getPort()) { if (LOG.isDebugEnabled()) LOG.debug("server already bound to port " + addr.getPort() + ", no need to rebind"); @@ -86,8 +94,7 @@ public class JettyHttpServer extends com.sun.net.httpserver.HttpServer this._addr = addr; if (LOG.isDebugEnabled()) LOG.debug("binding server to port " + addr.getPort()); - SelectChannelConnector connector = new SelectChannelConnector(); - connector.setAcceptors(1); + ServerConnector connector = new ServerConnector(_server); connector.setPort(addr.getPort()); connector.setHost(addr.getHostName()); _server.addConnector(connector); @@ -121,19 +128,20 @@ public class JettyHttpServer extends com.sun.net.httpserver.HttpServer { if (executor == null) throw new IllegalArgumentException("missing required 'executor' argument"); - - if (!(executor instanceof ThreadPoolExecutor)) - throw new IllegalArgumentException("only java.util.concurrent.ThreadPoolExecutor instances are allowed, got: " + executor.getClass().getName()); - - if (LOG.isDebugEnabled()) LOG.debug("using ThreadPoolExecutor for server thread pool"); - this._executor = (ThreadPoolExecutor) executor; - _server.setThreadPool(new ThreadPoolExecutorAdapter(_executor)); + ThreadPool threadPool = _server.getThreadPool(); + if (threadPool instanceof DelegatingThreadPool) + ((DelegatingThreadPool)_server.getThreadPool()).setExecutor(executor); + else + throw new UnsupportedOperationException("!DelegatingThreadPool"); } @Override public Executor getExecutor() { - return _executor; + ThreadPool threadPool = _server.getThreadPool(); + if (threadPool instanceof DelegatingThreadPool) + return ((DelegatingThreadPool)_server.getThreadPool()).getExecutor(); + return threadPool; } @Override diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java index b96d9a2b543..410ef2a992b 100644 --- a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java @@ -26,6 +26,9 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.ContextHandlerCollection; +import org.eclipse.jetty.util.thread.ExecutorThreadPool; +import org.eclipse.jetty.util.thread.QueuedThreadPool; +import org.eclipse.jetty.util.thread.ThreadPool; import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpsServer; @@ -53,11 +56,12 @@ public class JettyHttpServerProvider extends HttpServerProvider if (server == null) { - server = new Server(); - - HandlerCollection handlerCollection = new HandlerCollection(); - handlerCollection.setHandlers(new Handler[] {new ContextHandlerCollection(), new DefaultHandler()}); - server.setHandler(handlerCollection); + ThreadPool threadPool = new DelegatingThreadPool(new QueuedThreadPool()); + server = new Server(threadPool); + + HandlerCollection handlerCollection = new HandlerCollection(); + handlerCollection.setHandlers(new Handler[] {new ContextHandlerCollection(), new DefaultHandler()}); + server.setHandler(handlerCollection); shared = false; } diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/ThreadPoolExecutorAdapter.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/ThreadPoolExecutorAdapter.java deleted file mode 100644 index aaffe8e43e8..00000000000 --- a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/ThreadPoolExecutorAdapter.java +++ /dev/null @@ -1,124 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. -// -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html -// -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php -// -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== -// - -package org.eclipse.jetty.http.spi; - -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.eclipse.jetty.util.component.AbstractLifeCycle; -import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; - -import org.eclipse.jetty.util.thread.ThreadPool; - -/** - * Jetty {@link ThreadPool} that bridges requests to a {@link ThreadPoolExecutor}. - */ -public class ThreadPoolExecutorAdapter extends AbstractLifeCycle implements ThreadPool -{ - private static final Logger LOG = Log.getLogger(ThreadPoolExecutorAdapter.class); - - - private ThreadPoolExecutor executor; - - public ThreadPoolExecutorAdapter(ThreadPoolExecutor executor) - { - this.executor = executor; - } - - public boolean dispatch(Runnable job) - { - try - { - executor.execute(job); - return true; - } - catch(RejectedExecutionException e) - { - LOG.warn(e); - return false; - } - } - - public int getIdleThreads() - { - return executor.getPoolSize()-executor.getActiveCount(); - } - - public int getThreads() - { - return executor.getPoolSize(); - } - - public boolean isLowOnThreads() - { - return executor.getActiveCount()>=executor.getMaximumPoolSize(); - } - - public void join() throws InterruptedException - { - executor.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); - } - - - - public boolean isFailed() - { - return false; - } - - public boolean isRunning() - { - return !executor.isTerminated() && !executor.isTerminating(); - } - - public boolean isStarted() - { - return !executor.isTerminated() && !executor.isTerminating(); - } - - public boolean isStarting() - { - return false; - } - - public boolean isStopped() - { - return executor.isTerminated(); - } - - public boolean isStopping() - { - return executor.isTerminating(); - } - - protected void doStart() throws Exception - { - if (executor.isTerminated() || executor.isTerminating() || executor.isShutdown()) - throw new IllegalStateException("Cannot restart"); - } - - protected void doStop() throws Exception - { - executor.shutdown(); - if (!executor.awaitTermination(60, TimeUnit.SECONDS)) - executor.shutdownNow(); - } - -} diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java index eadb2f413c9..8e815d9acdd 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java @@ -98,6 +98,23 @@ public class ServerConnector extends AbstractNetworkConnector { this(server,null,null,null,0,0,new HttpConnectionFactory()); } + + /* ------------------------------------------------------------ */ + /** HTTP Server Connection. + *

Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the only factory.

+ * @param server The {@link Server} this connector will accept connection for. + * @param acceptors + * the number of acceptor threads to use, or 0 for a default value. Acceptors accept new TCP/IP connections. + * @param selectors + * the number of selector threads, or 0 for a default value. Selectors notice and schedule established connection that can make IO progress. + */ + public ServerConnector( + @Name("server") Server server, + @Name("acceptors") int acceptors, + @Name("selectors") int selectors) + { + this(server,null,null,null,acceptors,selectors,new HttpConnectionFactory()); + } /* ------------------------------------------------------------ */ /** Generic Server Connection with default configuration. diff --git a/pom.xml b/pom.xml index aebaa96269e..2869f6c0372 100644 --- a/pom.xml +++ b/pom.xml @@ -451,10 +451,10 @@ jetty-distribution jetty-runner jetty-monitor + jetty-http-spi jetty-overlay-deployer From 7df6b6b9ac27f658c08f289eaf1e3114bee44ed6 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 26 Jul 2013 12:13:08 +1000 Subject: [PATCH 5/6] added comment header --- .../jetty/http/spi/DelegatingThreadPool.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java index 245ca1db341..1a1ce7b14fa 100644 --- a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/DelegatingThreadPool.java @@ -1,3 +1,21 @@ +// +// ======================================================================== +// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + package org.eclipse.jetty.http.spi; import java.util.concurrent.Executor; From ea7854eccfcf74845f70cd05537171913dfb7aa1 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 26 Jul 2013 16:09:50 +1000 Subject: [PATCH 6/6] removed delicate external test --- .../test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java index 22f51ce04b7..e4de3f3e1d4 100644 --- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java +++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java @@ -26,6 +26,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; + import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; @@ -57,6 +58,7 @@ import org.hamcrest.Matchers; import org.junit.After; import org.junit.Assert; import org.junit.Assume; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -373,6 +375,7 @@ public class ProxyTunnellingTest } @Test + @Ignore // to delicate to rely on external proxy. public void testExternalProxy() throws Exception { // Free proxy server obtained from http://hidemyass.com/proxy-list/