Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2016-02-10 09:05:39 -0500
committerSimone Bordet2016-02-10 09:05:39 -0500
commit1bc4fe6d392e9522d2fb87da77e493f4cca759b0 (patch)
tree2e684ef6a19f3a9136a2892d05db26d25278a049
parent2ac465a34327c95efc3cc00b672e7ab4dced727c (diff)
parenta1a8f6aeae1597f709458a78fb683dd0562633b3 (diff)
downloadorg.eclipse.jetty.project-1bc4fe6d392e9522d2fb87da77e493f4cca759b0.tar.gz
org.eclipse.jetty.project-1bc4fe6d392e9522d2fb87da77e493f4cca759b0.tar.xz
org.eclipse.jetty.project-1bc4fe6d392e9522d2fb87da77e493f4cca759b0.zip
Merged branch 'jetty-9.3.x' into 'master'.
-rw-r--r--jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpConnectionOverHTTP2.java2
-rw-r--r--jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2Test.java32
2 files changed, 34 insertions, 0 deletions
diff --git a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpConnectionOverHTTP2.java b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpConnectionOverHTTP2.java
index 6bc69f99af..edc1987bd0 100644
--- a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpConnectionOverHTTP2.java
+++ b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpConnectionOverHTTP2.java
@@ -26,6 +26,7 @@ import org.eclipse.jetty.client.HttpConnection;
import org.eclipse.jetty.client.HttpDestination;
import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.client.SendFailure;
+import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.api.Session;
import org.eclipse.jetty.util.Callback;
@@ -50,6 +51,7 @@ public class HttpConnectionOverHTTP2 extends HttpConnection
@Override
protected SendFailure send(HttpExchange exchange)
{
+ exchange.getRequest().version(HttpVersion.HTTP_2);
normalizeRequest(exchange.getRequest());
// One connection maps to N channels, so for each exchange we create a new channel.
diff --git a/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2Test.java b/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2Test.java
index 1dcd6066d0..2f52810e07 100644
--- a/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2Test.java
+++ b/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2Test.java
@@ -18,12 +18,17 @@
package org.eclipse.jetty.http2.client.http;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpFields;
@@ -36,6 +41,8 @@ import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.http2.frames.DataFrame;
import org.eclipse.jetty.http2.frames.HeadersFrame;
import org.eclipse.jetty.http2.frames.ResetFrame;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
@@ -146,6 +153,31 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest
}
}
+ @Test
+ public void testRequestHasHTTP2Version() throws Exception
+ {
+ start(new AbstractHandler()
+ {
+ @Override
+ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ {
+ baseRequest.setHandled(true);
+ HttpVersion version = HttpVersion.fromString(request.getProtocol());
+ response.setStatus(version == HttpVersion.HTTP_2 ? HttpStatus.OK_200 : HttpStatus.INTERNAL_SERVER_ERROR_500);
+ }
+ });
+
+ ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
+ .onRequestBegin(request ->
+ {
+ if (request.getVersion() != HttpVersion.HTTP_2)
+ request.abort(new Exception("Not a HTTP/2 request"));
+ })
+ .send();
+
+ Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
+ }
+
@Ignore
@Test
public void testExternalServer() throws Exception

Back to the top