Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2015-11-04 07:40:44 -0500
committerSimone Bordet2015-11-04 07:40:44 -0500
commit7a3463139759f07278c1a112665e90a4262ce46d (patch)
treef2bff681b1756de31bcbc33c3f116b59df35a456
parent473d65884267a7fc57e10715f0c31dff8bcbe871 (diff)
parent0172b68301786e8b29e62865afe9ec9edfdf13d2 (diff)
downloadorg.eclipse.jetty.project-7a3463139759f07278c1a112665e90a4262ce46d.tar.gz
org.eclipse.jetty.project-7a3463139759f07278c1a112665e90a4262ce46d.tar.xz
org.eclipse.jetty.project-7a3463139759f07278c1a112665e90a4262ce46d.zip
Merged branch 'jetty-9.2.x' into 'jetty-9.3.x'.
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java2
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpClientServerTest.java8
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java56
3 files changed, 63 insertions, 3 deletions
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java
index da9fcd6e08..8108e5491c 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java
@@ -41,8 +41,8 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements Connec
private static final Logger LOG = Log.getLogger(HttpConnectionOverHTTP.class);
private final AtomicBoolean closed = new AtomicBoolean();
- private final Promise<Connection> promise;
private final AtomicInteger sweeps = new AtomicInteger();
+ private final Promise<Connection> promise;
private final Delegate delegate;
private final HttpChannelOverHTTP channel;
private long idleTimeout;
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpClientServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpClientServerTest.java
index edb6c9ce71..9cea0fd213 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpClientServerTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpClientServerTest.java
@@ -60,6 +60,12 @@ public abstract class AbstractHttpClientServerTest
public void start(Handler handler) throws Exception
{
+ startServer(handler);
+ startClient();
+ }
+
+ protected void startServer(Handler handler) throws Exception
+ {
if (sslContextFactory != null)
{
sslContextFactory.setEndpointIdentificationAlgorithm("");
@@ -79,8 +85,6 @@ public abstract class AbstractHttpClientServerTest
server.addConnector(connector);
server.setHandler(handler);
server.start();
-
- startClient();
}
protected void startClient() throws Exception
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
index bff369f79d..592d7d65ca 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
@@ -1486,6 +1486,62 @@ public class HttpClientTest extends AbstractHttpClientServerTest
}
@Test
+ public void testRequestSentOnlyAfterConnectionOpen() throws Exception
+ {
+ startServer(new AbstractHandler()
+ {
+ @Override
+ public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ {
+ baseRequest.setHandled(true);
+ }
+ });
+
+ final AtomicBoolean open = new AtomicBoolean();
+ client = new HttpClient(new HttpClientTransportOverHTTP()
+ {
+ @Override
+ protected HttpConnectionOverHTTP newHttpConnection(EndPoint endPoint, HttpDestination destination, Promise<Connection> promise)
+ {
+ return new HttpConnectionOverHTTP(endPoint, destination, promise)
+ {
+ @Override
+ public void onOpen()
+ {
+ open.set(true);
+ super.onOpen();
+ }
+ };
+ }
+ }, sslContextFactory);
+ client.start();
+
+ final CountDownLatch latch = new CountDownLatch(2);
+ client.newRequest("localhost", connector.getLocalPort())
+ .scheme(scheme)
+ .onRequestBegin(new Request.BeginListener()
+ {
+ @Override
+ public void onBegin(Request request)
+ {
+ Assert.assertTrue(open.get());
+ latch.countDown();
+ }
+ })
+ .send(new Response.CompleteListener()
+ {
+ @Override
+ public void onComplete(Result result)
+ {
+ if (result.isSucceeded())
+ latch.countDown();
+ }
+ });
+
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
+ }
+
+ @Test
public void testCONNECTWithHTTP10() throws Exception
{
try (ServerSocket server = new ServerSocket(0))

Back to the top