From dbd66b131b2eb6ebd3752df1c024858ac032decf Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 14 Sep 2015 11:49:45 +0200 Subject: [PATCH] Introduced a HeadersFrame constructor for HEADERS frames with unspecified stream id, to be used when creating new frames. --- .../jetty/http2/client/HTTP2Client.java | 2 +- .../jetty/http2/client/AsyncIOTest.java | 7 +-- .../eclipse/jetty/http2/client/Client.java | 4 +- .../http2/client/FlowControlStrategyTest.java | 36 +++++++-------- .../eclipse/jetty/http2/client/HTTP2Test.java | 16 +++---- .../jetty/http2/client/IdleTimeoutTest.java | 28 +++++------ .../jetty/http2/client/ProxyProtocolTest.java | 2 +- .../eclipse/jetty/http2/client/ProxyTest.java | 4 +- .../http2/client/PushCacheFilterTest.java | 46 +++++++++---------- .../http2/client/SessionFailureTest.java | 2 +- .../jetty/http2/client/StreamCloseTest.java | 24 +++++----- .../jetty/http2/client/StreamCountTest.java | 12 ++--- .../jetty/http2/client/StreamResetTest.java | 20 ++++---- .../jetty/http2/frames/HeadersFrame.java | 24 ++++++++++ .../eclipse/jetty/http2/api/UsageTest.java | 2 +- .../client/http/HttpSenderOverHTTP2.java | 2 +- 16 files changed, 128 insertions(+), 103 deletions(-) diff --git a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java index 90400fa9360..dad32dc8222 100644 --- a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java +++ b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java @@ -78,7 +78,7 @@ import org.eclipse.jetty.util.thread.Scheduler; * // Prepare the HTTP request object. * MetaData.Request request = new MetaData.Request("PUT", new HttpURI("https://" + host + ":" + port + "/"), HttpVersion.HTTP_2, requestFields); * // Create the HTTP/2 HEADERS frame representing the HTTP request. - * HeadersFrame headersFrame = new HeadersFrame(0, request, null, false); + * HeadersFrame headersFrame = new HeadersFrame(request, null, false); * * // Prepare the listener to receive the HTTP response frames. * Stream.Listener responseListener = new new Stream.Listener.Adapter() diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/AsyncIOTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/AsyncIOTest.java index 02ee1c29739..8a1aaa5ff43 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/AsyncIOTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/AsyncIOTest.java @@ -24,6 +24,7 @@ import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; + import javax.servlet.AsyncContext; import javax.servlet.ReadListener; import javax.servlet.ServletException; @@ -81,7 +82,7 @@ public class AsyncIOTest extends AbstractTest HttpFields fields = new HttpFields(); MetaData.Request metaData = newRequest("GET", fields); - HeadersFrame frame = new HeadersFrame(1, metaData, null, false); + HeadersFrame frame = new HeadersFrame(metaData, null, false); final CountDownLatch latch = new CountDownLatch(1); FuturePromise promise = new FuturePromise<>(); session.newStream(frame, promise, new Stream.Listener.Adapter() @@ -132,7 +133,7 @@ public class AsyncIOTest extends AbstractTest HttpFields fields = new HttpFields(); MetaData.Request metaData = newRequest("GET", fields); - HeadersFrame frame = new HeadersFrame(1, metaData, null, false); + HeadersFrame frame = new HeadersFrame(metaData, null, false); final CountDownLatch latch = new CountDownLatch(1); FuturePromise promise = new FuturePromise<>(); session.newStream(frame, promise, new Stream.Listener.Adapter() @@ -188,7 +189,7 @@ public class AsyncIOTest extends AbstractTest HttpFields fields = new HttpFields(); MetaData.Request metaData = newRequest("GET", fields); - HeadersFrame frame = new HeadersFrame(1, metaData, null, false); + HeadersFrame frame = new HeadersFrame(metaData, null, false); final CountDownLatch latch = new CountDownLatch(1); FuturePromise promise = new FuturePromise<>(); session.newStream(frame, promise, new Stream.Listener.Adapter() diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/Client.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/Client.java index 801c6b71c94..ffefc8c0280 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/Client.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/Client.java @@ -57,9 +57,9 @@ public class Client HttpFields requestFields = new HttpFields(); requestFields.put("User-Agent", client.getClass().getName() + "/" + Jetty.VERSION); MetaData.Request metaData = new MetaData.Request("GET", new HttpURI("https://" + host + ":" + port + "/"), HttpVersion.HTTP_2, requestFields); - HeadersFrame headersFrame = new HeadersFrame(0, metaData, null, true); + HeadersFrame headersFrame = new HeadersFrame(metaData, null, true); final Phaser phaser = new Phaser(2); - session.newStream(headersFrame, new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(headersFrame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onHeaders(Stream stream, HeadersFrame frame) diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/FlowControlStrategyTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/FlowControlStrategyTest.java index f19c7844bcc..5ea92308e71 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/FlowControlStrategyTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/FlowControlStrategyTest.java @@ -195,7 +195,7 @@ public abstract class FlowControlStrategyTest MetaData.Request request1 = newRequest("GET", new HttpFields()); FuturePromise promise1 = new FuturePromise<>(); - clientSession.newStream(new HeadersFrame(0, request1, null, true), promise1, new Stream.Listener.Adapter()); + clientSession.newStream(new HeadersFrame(request1, null, true), promise1, new Stream.Listener.Adapter()); HTTP2Stream clientStream1 = (HTTP2Stream)promise1.get(5, TimeUnit.SECONDS); Assert.assertEquals(FlowControlStrategy.DEFAULT_WINDOW_SIZE, clientStream1.getSendWindow()); @@ -219,7 +219,7 @@ public abstract class FlowControlStrategyTest // Now create a new stream, it must pick up the new value. MetaData.Request request2 = newRequest("POST", new HttpFields()); FuturePromise promise2 = new FuturePromise<>(); - clientSession.newStream(new HeadersFrame(0, request2, null, true), promise2, new Stream.Listener.Adapter()); + clientSession.newStream(new HeadersFrame(request2, null, true), promise2, new Stream.Listener.Adapter()); HTTP2Stream clientStream2 = (HTTP2Stream)promise2.get(5, TimeUnit.SECONDS); Assert.assertEquals(FlowControlStrategy.DEFAULT_WINDOW_SIZE, clientStream2.getSendWindow()); @@ -289,7 +289,7 @@ public abstract class FlowControlStrategyTest MetaData.Request request = newRequest("POST", new HttpFields()); FuturePromise promise = new FuturePromise<>(); - session.newStream(new HeadersFrame(0, request, null, false), promise, new Stream.Listener.Adapter()); + session.newStream(new HeadersFrame(request, null, false), promise, new Stream.Listener.Adapter()); Stream stream = promise.get(5, TimeUnit.SECONDS); // Send first chunk that exceeds the window. @@ -344,8 +344,8 @@ public abstract class FlowControlStrategyTest final CountDownLatch dataLatch = new CountDownLatch(1); final Exchanger exchanger = new Exchanger<>(); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true); - session.newStream(requestFrame, new Promise.Adapter(), new Stream.Listener.Adapter() + HeadersFrame requestFrame = new HeadersFrame(metaData, null, true); + session.newStream(requestFrame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { private AtomicInteger dataFrames = new AtomicInteger(); @@ -467,7 +467,7 @@ public abstract class FlowControlStrategyTest Assert.assertTrue(settingsLatch.await(5, TimeUnit.SECONDS)); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, false); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, false); FuturePromise streamPromise = new FuturePromise<>(); session.newStream(requestFrame, streamPromise, null); Stream stream = streamPromise.get(5, TimeUnit.SECONDS); @@ -541,7 +541,7 @@ public abstract class FlowControlStrategyTest final List callbacks1 = new ArrayList<>(); final CountDownLatch prepareLatch = new CountDownLatch(1); MetaData.Request request1 = newRequest("POST", new HttpFields()); - session.newStream(new HeadersFrame(0, request1, null, true), new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(request1, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -556,7 +556,7 @@ public abstract class FlowControlStrategyTest // Second request will consume half of the remaining the session window. MetaData.Request request2 = newRequest("GET", new HttpFields()); - session.newStream(new HeadersFrame(0, request2, null, true), new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(request2, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -568,7 +568,7 @@ public abstract class FlowControlStrategyTest // Third request will consume the whole session window, which is now stalled. // A fourth request will not be able to receive data. MetaData.Request request3 = newRequest("GET", new HttpFields()); - session.newStream(new HeadersFrame(0, request3, null, true), new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(request3, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -580,7 +580,7 @@ public abstract class FlowControlStrategyTest // Fourth request is now stalled. final CountDownLatch latch = new CountDownLatch(1); MetaData.Request request4 = newRequest("GET", new HttpFields()); - session.newStream(new HeadersFrame(0, request4, null, true), new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(request4, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -624,10 +624,10 @@ public abstract class FlowControlStrategyTest Session session = newClient(new Session.Listener.Adapter()); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, true); final byte[] bytes = new byte[data.length]; final CountDownLatch latch = new CountDownLatch(1); - session.newStream(requestFrame, new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(requestFrame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { private int received; @@ -691,9 +691,9 @@ public abstract class FlowControlStrategyTest byte[] content = new byte[chunk1.length + chunk2.length]; final ByteBuffer buffer = ByteBuffer.wrap(content); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, true); final CountDownLatch responseLatch = new CountDownLatch(1); - session.newStream(requestFrame, new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(requestFrame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -769,7 +769,7 @@ public abstract class FlowControlStrategyTest byte[] responseData = new byte[requestData.length]; final ByteBuffer responseContent = ByteBuffer.wrap(responseData); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, false); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, false); FuturePromise streamPromise = new FuturePromise<>(); final CountDownLatch latch = new CountDownLatch(1); session.newStream(requestFrame, streamPromise, new Stream.Listener.Adapter() @@ -814,7 +814,7 @@ public abstract class FlowControlStrategyTest // Consume the whole session and stream window. MetaData.Request metaData = newRequest("POST", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, false); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, false); FuturePromise streamPromise = new FuturePromise<>(); session.newStream(requestFrame, streamPromise, new Stream.Listener.Adapter()); Stream stream = streamPromise.get(5, TimeUnit.SECONDS); @@ -879,7 +879,7 @@ public abstract class FlowControlStrategyTest // Consume the whole stream window. MetaData.Request metaData = newRequest("POST", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, false); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, false); FuturePromise streamPromise = new FuturePromise<>(); session.newStream(requestFrame, streamPromise, new Stream.Listener.Adapter()); Stream stream = streamPromise.get(5, TimeUnit.SECONDS); @@ -944,7 +944,7 @@ public abstract class FlowControlStrategyTest Session session = newClient(new Session.Listener.Adapter()); MetaData.Request metaData = newRequest("POST", new HttpFields()); - HeadersFrame frame = new HeadersFrame(0, metaData, null, false); + HeadersFrame frame = new HeadersFrame(metaData, null, false); FuturePromise streamPromise = new FuturePromise<>(); final CountDownLatch resetLatch = new CountDownLatch(1); session.newStream(frame, streamPromise, new Stream.Listener.Adapter() diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/HTTP2Test.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/HTTP2Test.java index a2cc06b17fc..4cf327a7311 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/HTTP2Test.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/HTTP2Test.java @@ -56,9 +56,9 @@ public class HTTP2Test extends AbstractTest HttpFields fields = new HttpFields(); MetaData.Request metaData = newRequest("GET", fields); - HeadersFrame frame = new HeadersFrame(1, metaData, null, true); + HeadersFrame frame = new HeadersFrame(metaData, null, true); final CountDownLatch latch = new CountDownLatch(1); - session.newStream(frame, new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onHeaders(Stream stream, HeadersFrame frame) @@ -95,9 +95,9 @@ public class HTTP2Test extends AbstractTest HttpFields fields = new HttpFields(); MetaData.Request metaData = newRequest("GET", fields); - HeadersFrame frame = new HeadersFrame(1, metaData, null, true); + HeadersFrame frame = new HeadersFrame(metaData, null, true); final CountDownLatch latch = new CountDownLatch(2); - session.newStream(frame, new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onHeaders(Stream stream, HeadersFrame frame) @@ -151,11 +151,11 @@ public class HTTP2Test extends AbstractTest fields.putLongField(downloadBytes, random.nextInt(128 * 1024)); fields.put("User-Agent", "HTTP2Client/" + Jetty.VERSION); MetaData.Request metaData = newRequest("GET", fields); - HeadersFrame frame = new HeadersFrame(1, metaData, null, true); + HeadersFrame frame = new HeadersFrame(metaData, null, true); final CountDownLatch latch = new CountDownLatch(requests); for (int i = 0; i < requests; ++i) { - session.newStream(frame, new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -186,7 +186,7 @@ public class HTTP2Test extends AbstractTest Session session = newClient(new Session.Listener.Adapter()); HttpFields fields = new HttpFields(); MetaData.Request metaData = newRequest("GET", fields); - HeadersFrame frame = new HeadersFrame(1, metaData, null, true); + HeadersFrame frame = new HeadersFrame(metaData, null, true); final CountDownLatch latch = new CountDownLatch(1); session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @@ -223,7 +223,7 @@ public class HTTP2Test extends AbstractTest Session session = newClient(new Session.Listener.Adapter()); HostPortHttpField hostHeader = new HostPortHttpField(authority); MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, hostHeader, servletPath, HttpVersion.HTTP_2, new HttpFields()); - HeadersFrame frame = new HeadersFrame(1, metaData, null, true); + HeadersFrame frame = new HeadersFrame(metaData, null, true); final CountDownLatch latch = new CountDownLatch(1); session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java index e99d570a6ee..f03a3f6699b 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java @@ -19,9 +19,6 @@ package org.eclipse.jetty.http2.client; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.junit.Assert.assertThat; - import java.io.IOException; import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; @@ -50,6 +47,9 @@ import org.eclipse.jetty.util.Promise; import org.junit.Assert; import org.junit.Test; +import static org.hamcrest.core.IsInstanceOf.instanceOf; +import static org.junit.Assert.assertThat; + public class IdleTimeoutTest extends AbstractTest { private final int idleTimeout = 1000; @@ -83,7 +83,7 @@ public class IdleTimeoutTest extends AbstractTest }); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, true); session.newStream(requestFrame, new Promise.Adapter() { @Override @@ -125,7 +125,7 @@ public class IdleTimeoutTest extends AbstractTest // The request is not replied, and the server should idle timeout. MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, true); session.newStream(requestFrame, new Promise.Adapter() { @Override @@ -172,7 +172,7 @@ public class IdleTimeoutTest extends AbstractTest final CountDownLatch replyLatch = new CountDownLatch(1); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, true); session.newStream(requestFrame, new Promise.Adapter() { @Override @@ -222,7 +222,7 @@ public class IdleTimeoutTest extends AbstractTest Session session = newClient(new Session.Listener.Adapter()); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, true); session.newStream(requestFrame, new Promise.Adapter() { @Override @@ -260,7 +260,7 @@ public class IdleTimeoutTest extends AbstractTest Session session = newClient(new Session.Listener.Adapter()); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, true); session.newStream(requestFrame, new Promise.Adapter() { @Override @@ -301,7 +301,7 @@ public class IdleTimeoutTest extends AbstractTest final CountDownLatch replyLatch = new CountDownLatch(1); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, true); session.newStream(requestFrame, new Promise.Adapter() { @Override @@ -344,7 +344,7 @@ public class IdleTimeoutTest extends AbstractTest final CountDownLatch dataLatch = new CountDownLatch(1); final CountDownLatch timeoutLatch = new CountDownLatch(1); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, true); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, true); session.newStream(requestFrame, new Promise.Adapter() { @Override @@ -403,8 +403,8 @@ public class IdleTimeoutTest extends AbstractTest Session session = newClient(new Session.Listener.Adapter()); MetaData.Request metaData = newRequest("GET", new HttpFields()); // Stream does not end here, but we won't send any DATA frame. - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, false); - session.newStream(requestFrame, new Promise.Adapter(), new Stream.Listener.Adapter() + HeadersFrame requestFrame = new HeadersFrame(metaData, null, false); + session.newStream(requestFrame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onReset(Stream stream, ResetFrame frame) @@ -445,7 +445,7 @@ public class IdleTimeoutTest extends AbstractTest Session session = newClient(new Session.Listener.Adapter()); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, false); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, false); FuturePromise promise = new FuturePromise<>(); session.newStream(requestFrame, promise, new Stream.Listener.Adapter()); final Stream stream = promise.get(5, TimeUnit.SECONDS); @@ -499,7 +499,7 @@ public class IdleTimeoutTest extends AbstractTest Session session = newClient(new Session.Listener.Adapter()); MetaData.Request metaData = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, metaData, null, false); + HeadersFrame requestFrame = new HeadersFrame(metaData, null, false); FuturePromise promise = new FuturePromise() { @Override diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyProtocolTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyProtocolTest.java index 639ed3ba295..650cc26746d 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyProtocolTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyProtocolTest.java @@ -103,7 +103,7 @@ public class ProxyProtocolTest HttpFields fields = new HttpFields(); String uri = "http://localhost:" + connector.getLocalPort() + "/"; MetaData.Request metaData = new MetaData.Request("GET", new HttpURI(uri), HttpVersion.HTTP_2, fields); - HeadersFrame frame = new HeadersFrame(1, metaData, null, true); + HeadersFrame frame = new HeadersFrame(metaData, null, true); CountDownLatch latch = new CountDownLatch(1); session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyTest.java index 222b7940db9..8a06ee3a862 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyTest.java @@ -170,8 +170,8 @@ public class ProxyTest final CountDownLatch clientLatch = new CountDownLatch(1); Session session = newClient(new Session.Listener.Adapter()); MetaData.Request metaData = newRequest("GET", "/", new HttpFields()); - HeadersFrame frame = new HeadersFrame(1, metaData, null, true); - session.newStream(frame, new Promise.Adapter(), new Stream.Listener.Adapter() + HeadersFrame frame = new HeadersFrame(metaData, null, true); + session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/PushCacheFilterTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/PushCacheFilterTest.java index 8907abb7c57..4088d95d397 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/PushCacheFilterTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/PushCacheFilterTest.java @@ -84,7 +84,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields primaryFields = new HttpFields(); MetaData.Request primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch warmupLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -96,7 +96,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields secondaryFields = new HttpFields(); secondaryFields.put(HttpHeader.REFERER, referrerURI); MetaData.Request secondaryRequest = newRequest("GET", secondaryResource, secondaryFields); - session.newStream(new HeadersFrame(0, secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -113,7 +113,7 @@ public class PushCacheFilterTest extends AbstractTest primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch primaryResponseLatch = new CountDownLatch(1); final CountDownLatch pushLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public Stream.Listener onPush(Stream stream, PushPromiseFrame frame) @@ -171,7 +171,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields primaryFields = new HttpFields(); MetaData.Request primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch warmupLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -183,7 +183,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields secondaryFields = new HttpFields(); secondaryFields.put(HttpHeader.REFERER, referrerURI); MetaData.Request secondaryRequest = newRequest("GET", secondaryResource, secondaryFields); - session.newStream(new HeadersFrame(0, secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -200,7 +200,7 @@ public class PushCacheFilterTest extends AbstractTest primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch primaryResponseLatch = new CountDownLatch(1); final CountDownLatch pushLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public Stream.Listener onPush(Stream stream, PushPromiseFrame frame) @@ -256,7 +256,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields primaryFields = new HttpFields(); MetaData.Request primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch warmupLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -268,7 +268,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields secondaryFields = new HttpFields(); secondaryFields.put(HttpHeader.REFERER, primaryURI); MetaData.Request secondaryRequest = newRequest("GET", secondaryResource, secondaryFields); - session.newStream(new HeadersFrame(0, secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -285,7 +285,7 @@ public class PushCacheFilterTest extends AbstractTest primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch primaryResponseLatch = new CountDownLatch(1); final CountDownLatch pushLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public Stream.Listener onPush(Stream stream, PushPromiseFrame frame) @@ -320,7 +320,7 @@ public class PushCacheFilterTest extends AbstractTest secondaryFields.put(HttpHeader.REFERER, primaryURI); MetaData.Request secondaryRequest = newRequest("GET", secondaryResource, secondaryFields); final CountDownLatch secondaryResponseLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -356,7 +356,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields primaryFields = new HttpFields(); MetaData.Request primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch warmupLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onHeaders(Stream stream, HeadersFrame frame) @@ -367,7 +367,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields secondaryFields = new HttpFields(); secondaryFields.put(HttpHeader.REFERER, primaryURI); MetaData.Request secondaryRequest = newRequest("GET", secondaryResource, secondaryFields); - session.newStream(new HeadersFrame(0, secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -386,7 +386,7 @@ public class PushCacheFilterTest extends AbstractTest primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch primaryResponseLatch = new CountDownLatch(1); final CountDownLatch pushLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onHeaders(Stream stream, HeadersFrame frame) @@ -443,7 +443,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields primaryFields = new HttpFields(); MetaData.Request primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch warmupLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -456,7 +456,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields secondaryFields = new HttpFields(); secondaryFields.put(HttpHeader.REFERER, primaryURI); MetaData.Request secondaryRequest = newRequest("GET", secondaryResource, secondaryFields); - session.newStream(new HeadersFrame(0, secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -468,7 +468,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields tertiaryFields = new HttpFields(); tertiaryFields.put(HttpHeader.REFERER, secondaryURI); MetaData.Request tertiaryRequest = newRequest("GET", tertiaryResource, tertiaryFields); - session.newStream(new HeadersFrame(0, tertiaryRequest, null, true), new Promise.Adapter<>(), new Adapter() + session.newStream(new HeadersFrame(tertiaryRequest, null, true), new Promise.Adapter<>(), new Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -491,7 +491,7 @@ public class PushCacheFilterTest extends AbstractTest primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch primaryResponseLatch = new CountDownLatch(1); final CountDownLatch pushLatch = new CountDownLatch(2); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -568,7 +568,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields primaryFields = new HttpFields(); MetaData.Request primaryRequest = newRequest("GET", primaryResource + "?credentials=wrong", primaryFields); final CountDownLatch warmupLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onHeaders(Stream stream, HeadersFrame frame) @@ -583,7 +583,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields redirectFields = new HttpFields(); redirectFields.put(HttpHeader.REFERER, primaryURI); MetaData.Request redirectRequest = newRequest("GET", location, redirectFields); - session.newStream(new HeadersFrame(0, redirectRequest, null, true), new Promise.Adapter<>(), new Adapter() + session.newStream(new HeadersFrame(redirectRequest, null, true), new Promise.Adapter<>(), new Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -604,7 +604,7 @@ public class PushCacheFilterTest extends AbstractTest primaryRequest = newRequest("GET", primaryResource + "?credentials=secret", primaryFields); final CountDownLatch primaryResponseLatch = new CountDownLatch(1); final CountDownLatch pushLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onData(Stream stream, DataFrame frame, Callback callback) @@ -659,7 +659,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields primaryFields = new HttpFields(); MetaData.Request primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch warmupLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onHeaders(Stream stream, HeadersFrame frame) @@ -670,7 +670,7 @@ public class PushCacheFilterTest extends AbstractTest HttpFields secondaryFields = new HttpFields(); secondaryFields.put(HttpHeader.REFERER, primaryURI); MetaData.Request secondaryRequest = newRequest("GET", secondaryResource, secondaryFields); - session.newStream(new HeadersFrame(0, secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(secondaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onHeaders(Stream stream, HeadersFrame frame) @@ -690,7 +690,7 @@ public class PushCacheFilterTest extends AbstractTest primaryRequest = newRequest("GET", primaryResource, primaryFields); final CountDownLatch primaryResponseLatch = new CountDownLatch(1); final CountDownLatch pushLatch = new CountDownLatch(1); - session.newStream(new HeadersFrame(0, primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() + session.newStream(new HeadersFrame(primaryRequest, null, true), new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public Stream.Listener onPush(Stream stream, PushPromiseFrame frame) diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/SessionFailureTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/SessionFailureTest.java index f9b3440b48c..ff08e0afeec 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/SessionFailureTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/SessionFailureTest.java @@ -111,7 +111,7 @@ public class SessionFailureTest extends AbstractTest clientFailureLatch.countDown(); } }); - HeadersFrame frame = new HeadersFrame(0, newRequest("GET", new HttpFields()), null, true); + HeadersFrame frame = new HeadersFrame(newRequest("GET", new HttpFields()), null, true); Promise promise = new Promise.Adapter<>(); session.newStream(frame, promise, null); diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCloseTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCloseTest.java index b5c4e346ca5..8a86944f372 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCloseTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCloseTest.java @@ -61,7 +61,7 @@ public class StreamCloseTest extends AbstractTest }); Session session = newClient(new Session.Listener.Adapter()); - HeadersFrame frame = new HeadersFrame(0, newRequest("GET", new HttpFields()), null, true); + HeadersFrame frame = new HeadersFrame(newRequest("GET", new HttpFields()), null, true); FuturePromise promise = new FuturePromise<>(); session.newStream(frame, promise, null); Stream stream = promise.get(5, TimeUnit.SECONDS); @@ -95,7 +95,7 @@ public class StreamCloseTest extends AbstractTest }); Session session = newClient(new Session.Listener.Adapter()); - HeadersFrame frame = new HeadersFrame(0, newRequest("GET", new HttpFields()), null, true); + HeadersFrame frame = new HeadersFrame(newRequest("GET", new HttpFields()), null, true); FuturePromise promise = new FuturePromise<>(); session.newStream(frame, promise, new Stream.Listener.Adapter() { @@ -147,7 +147,7 @@ public class StreamCloseTest extends AbstractTest final CountDownLatch completeLatch = new CountDownLatch(1); Session session = newClient(new Session.Listener.Adapter()); - HeadersFrame frame = new HeadersFrame(0, newRequest("GET", new HttpFields()), null, false); + HeadersFrame frame = new HeadersFrame(newRequest("GET", new HttpFields()), null, false); FuturePromise promise = new FuturePromise<>(); session.newStream(frame, promise, new Stream.Listener.Adapter() { @@ -216,9 +216,9 @@ public class StreamCloseTest extends AbstractTest }); Session session = newClient(new Session.Listener.Adapter()); - HeadersFrame frame = new HeadersFrame(0, newRequest("GET", new HttpFields()), null, true); + HeadersFrame frame = new HeadersFrame(newRequest("GET", new HttpFields()), null, true); final CountDownLatch clientLatch = new CountDownLatch(1); - session.newStream(frame, new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public Stream.Listener onPush(Stream pushedStream, PushPromiseFrame frame) @@ -251,7 +251,7 @@ public class StreamCloseTest extends AbstractTest public Stream.Listener onNewStream(final Stream stream, HeadersFrame frame) { PushPromiseFrame pushFrame = new PushPromiseFrame(stream.getId(), 0, newRequest("GET", new HttpFields())); - stream.push(pushFrame, new Promise.Adapter(), new Stream.Listener.Adapter() + stream.push(pushFrame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public void onReset(Stream pushedStream, ResetFrame frame) @@ -268,9 +268,9 @@ public class StreamCloseTest extends AbstractTest }); Session session = newClient(new Session.Listener.Adapter()); - HeadersFrame frame = new HeadersFrame(0, newRequest("GET", new HttpFields()), null, true); + HeadersFrame frame = new HeadersFrame(newRequest("GET", new HttpFields()), null, true); final CountDownLatch clientLatch = new CountDownLatch(2); - session.newStream(frame, new Promise.Adapter(), new Stream.Listener.Adapter() + session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() { @Override public Stream.Listener onPush(final Stream pushedStream, PushPromiseFrame frame) @@ -333,12 +333,12 @@ public class StreamCloseTest extends AbstractTest Session session = newClient(new Session.Listener.Adapter()); // First stream will be idle on server. - HeadersFrame request1 = new HeadersFrame(0, newRequest("HEAD", new HttpFields()), null, true); - session.newStream(request1, new Promise.Adapter(), new Stream.Listener.Adapter()); + HeadersFrame request1 = new HeadersFrame(newRequest("HEAD", new HttpFields()), null, true); + session.newStream(request1, new Promise.Adapter<>(), new Stream.Listener.Adapter()); // Second stream will fail on server. - HeadersFrame request2 = new HeadersFrame(0, newRequest("GET", new HttpFields()), null, true); - session.newStream(request2, new Promise.Adapter(), new Stream.Listener.Adapter()); + HeadersFrame request2 = new HeadersFrame(newRequest("GET", new HttpFields()), null, true); + session.newStream(request2, new Promise.Adapter<>(), new Stream.Listener.Adapter()); Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); } diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCountTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCountTest.java index 7a65df8fa1d..2072e1b0110 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCountTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCountTest.java @@ -89,7 +89,7 @@ public class StreamCountTest extends AbstractTest HttpFields fields = new HttpFields(); MetaData.Request metaData = newRequest("GET", fields); - HeadersFrame frame1 = new HeadersFrame(1, metaData, null, false); + HeadersFrame frame1 = new HeadersFrame(metaData, null, false); FuturePromise streamPromise1 = new FuturePromise<>(); final CountDownLatch responseLatch = new CountDownLatch(1); session.newStream(frame1, streamPromise1, new Stream.Listener.Adapter() @@ -103,7 +103,7 @@ public class StreamCountTest extends AbstractTest }); Stream stream1 = streamPromise1.get(5, TimeUnit.SECONDS); - HeadersFrame frame2 = new HeadersFrame(3, metaData, null, false); + HeadersFrame frame2 = new HeadersFrame(metaData, null, false); FuturePromise streamPromise2 = new FuturePromise<>(); session.newStream(frame2, streamPromise2, new Stream.Listener.Adapter()); @@ -117,7 +117,7 @@ public class StreamCountTest extends AbstractTest // Expected } - stream1.data(new DataFrame(stream1.getId(), BufferUtil.EMPTY_BUFFER, true), new Callback.Adapter()); + stream1.data(new DataFrame(stream1.getId(), BufferUtil.EMPTY_BUFFER, true), Callback.NOOP); Assert.assertTrue(responseLatch.await(5, TimeUnit.SECONDS)); } @@ -153,7 +153,7 @@ public class StreamCountTest extends AbstractTest HttpFields fields = new HttpFields(); MetaData.Request metaData = newRequest("GET", fields); - HeadersFrame frame1 = new HeadersFrame(1, metaData, null, false); + HeadersFrame frame1 = new HeadersFrame(metaData, null, false); FuturePromise streamPromise1 = new FuturePromise<>(); final CountDownLatch responseLatch = new CountDownLatch(1); session.newStream(frame1, streamPromise1, new Stream.Listener.Adapter() @@ -168,7 +168,7 @@ public class StreamCountTest extends AbstractTest Stream stream1 = streamPromise1.get(5, TimeUnit.SECONDS); - HeadersFrame frame2 = new HeadersFrame(3, metaData, null, false); + HeadersFrame frame2 = new HeadersFrame(metaData, null, false); FuturePromise streamPromise2 = new FuturePromise<>(); session.newStream(frame2, streamPromise2, new Stream.Listener.Adapter() { @@ -182,7 +182,7 @@ public class StreamCountTest extends AbstractTest streamPromise2.get(5, TimeUnit.SECONDS); Assert.assertTrue(resetLatch.await(5, TimeUnit.SECONDS)); - stream1.data(new DataFrame(stream1.getId(), BufferUtil.EMPTY_BUFFER, true), new Callback.Adapter()); + stream1.data(new DataFrame(stream1.getId(), BufferUtil.EMPTY_BUFFER, true), Callback.NOOP); Assert.assertTrue(responseLatch.await(5, TimeUnit.SECONDS)); } } diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java index da8051e1f6d..7e5d60e5ca4 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java @@ -59,7 +59,7 @@ public class StreamResetTest extends AbstractTest Session client = newClient(new Session.Listener.Adapter()); MetaData.Request request = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, request, null, false); + HeadersFrame requestFrame = new HeadersFrame(request, null, false); FuturePromise promise = new FuturePromise<>(); client.newStream(requestFrame, promise, new Stream.Listener.Adapter()); Stream stream = promise.get(5, TimeUnit.SECONDS); @@ -97,7 +97,7 @@ public class StreamResetTest extends AbstractTest Session client = newClient(new Session.Listener.Adapter()); MetaData.Request request = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame = new HeadersFrame(0, request, null, false); + HeadersFrame requestFrame = new HeadersFrame(request, null, false); FuturePromise promise = new FuturePromise<>(); client.newStream(requestFrame, promise, new Stream.Listener.Adapter()); Stream stream = promise.get(5, TimeUnit.SECONDS); @@ -156,7 +156,7 @@ public class StreamResetTest extends AbstractTest Session client = newClient(new Session.Listener.Adapter()); MetaData.Request request1 = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame1 = new HeadersFrame(0, request1, null, false); + HeadersFrame requestFrame1 = new HeadersFrame(request1, null, false); FuturePromise promise1 = new FuturePromise<>(); final CountDownLatch stream1HeadersLatch = new CountDownLatch(1); final CountDownLatch stream1DataLatch = new CountDownLatch(1); @@ -178,7 +178,7 @@ public class StreamResetTest extends AbstractTest Assert.assertTrue(stream1HeadersLatch.await(5, TimeUnit.SECONDS)); MetaData.Request request2 = newRequest("GET", new HttpFields()); - HeadersFrame requestFrame2 = new HeadersFrame(0, request2, null, false); + HeadersFrame requestFrame2 = new HeadersFrame(request2, null, false); FuturePromise promise2 = new FuturePromise<>(); final CountDownLatch stream2DataLatch = new CountDownLatch(1); client.newStream(requestFrame2, promise2, new Stream.Listener.Adapter() @@ -237,7 +237,7 @@ public class StreamResetTest extends AbstractTest // Write some content after the stream has // been reset, it should throw an exception. for (int i=0;i<10;i++) - { + { Thread.sleep(500); response.getOutputStream().write(data); response.flushBuffer(); @@ -245,7 +245,7 @@ public class StreamResetTest extends AbstractTest } catch (InterruptedException x) { - + } catch (IOException x) { @@ -256,8 +256,8 @@ public class StreamResetTest extends AbstractTest Session client = newClient(new Session.Listener.Adapter()); MetaData.Request request = newRequest("GET", new HttpFields()); - HeadersFrame frame = new HeadersFrame(0, request, null, true); - client.newStream(frame, new FuturePromise(), new Stream.Listener.Adapter() + HeadersFrame frame = new HeadersFrame(request, null, true); + client.newStream(frame, new FuturePromise<>(), new Stream.Listener.Adapter() { @Override public void onHeaders(Stream stream, HeadersFrame frame) @@ -335,8 +335,8 @@ public class StreamResetTest extends AbstractTest Session client = newClient(new Session.Listener.Adapter()); MetaData.Request request = newRequest("GET", new HttpFields()); - HeadersFrame frame = new HeadersFrame(0, request, null, true); - client.newStream(frame, new FuturePromise(), new Stream.Listener.Adapter() + HeadersFrame frame = new HeadersFrame(request, null, true); + client.newStream(frame, new FuturePromise<>(), new Stream.Listener.Adapter() { @Override public void onHeaders(Stream stream, HeadersFrame frame) diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/frames/HeadersFrame.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/frames/HeadersFrame.java index 15cb149cd85..71ebd4f6edc 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/frames/HeadersFrame.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/frames/HeadersFrame.java @@ -27,6 +27,30 @@ public class HeadersFrame extends Frame private final PriorityFrame priority; private final boolean endStream; + /** + *

Creates a new {@code HEADERS} frame with an unspecified stream {@code id}.

+ *

The stream {@code id} will be generated by the implementation while sending + * this frame to the other peer.

+ * + * @param metaData the metadata containing HTTP request information + * @param priority the PRIORITY frame associated with this HEADERS frame + * @param endStream whether this frame ends the stream + */ + public HeadersFrame(MetaData metaData, PriorityFrame priority, boolean endStream) + { + this(0, metaData, priority, endStream); + } + + /** + *

Creates a new {@code HEADERS} frame with the specified stream {@code id}.

+ *

{@code HEADERS} frames with a specific stream {@code id} are typically used + * in responses to request {@code HEADERS} frames.

+ * + * @param streamId the stream id + * @param metaData the metadata containing HTTP request/response information + * @param priority the PRIORITY frame associated with this HEADERS frame + * @param endStream whether this frame ends the stream + */ public HeadersFrame(int streamId, MetaData metaData, PriorityFrame priority, boolean endStream) { super(FrameType.HEADERS); diff --git a/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/api/UsageTest.java b/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/api/UsageTest.java index 353516cb7ac..88ad1bb7cb0 100644 --- a/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/api/UsageTest.java +++ b/jetty-http2/http2-common/src/test/java/org/eclipse/jetty/http2/api/UsageTest.java @@ -33,7 +33,7 @@ public class UsageTest // @Override // public void succeeded(Session session) // { -// session.newStream(new HeadersFrame(0, info, null, true), new Stream.Listener.Adapter() +// session.newStream(new HeadersFrame(info, null, true), new Stream.Listener.Adapter() // { // @Override // public void onData(Stream stream, DataFrame frame) diff --git a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpSenderOverHTTP2.java b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpSenderOverHTTP2.java index 9b7e5b0c00f..1506f37f2c1 100644 --- a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpSenderOverHTTP2.java +++ b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpSenderOverHTTP2.java @@ -52,7 +52,7 @@ public class HttpSenderOverHTTP2 extends HttpSender final Request request = exchange.getRequest(); HttpURI uri = new HttpURI(request.getScheme(), request.getHost(), request.getPort(), request.getPath(), null, request.getQuery(), null); MetaData.Request metaData = new MetaData.Request(request.getMethod(), uri, HttpVersion.HTTP_2, request.getHeaders()); - HeadersFrame headersFrame = new HeadersFrame(0, metaData, null, !content.hasContent()); + HeadersFrame headersFrame = new HeadersFrame(metaData, null, !content.hasContent()); HttpChannelOverHTTP2 channel = getHttpChannel(); Promise promise = new Promise() {