From 1326700772ad9c43b0b36ed70eef2803855324aa Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 19 Mar 2020 23:10:03 +0100 Subject: [PATCH] Issue #4382 - Support HTTP/1 upgrade to HTTP/2 in HttpClient. Added comments and fixed logging. Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/client/http/HttpSenderOverHTTP.java | 6 +++--- .../org/eclipse/jetty/client/http/ProtocolHttpUpgrader.java | 6 +++--- .../http2/client/http/ClientConnectionFactoryOverHTTP2.java | 3 +++ .../jetty/http2/client/http/HttpSenderOverHTTP2.java | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java index 99d84198dab..b3e88b836df 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java @@ -35,12 +35,12 @@ import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IteratingCallback; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HttpSenderOverHTTP extends HttpSender { - private static final Logger LOG = Log.getLogger(HttpSenderOverHTTP.class); + private static final Logger LOG = LoggerFactory.getLogger(HttpSenderOverHTTP.class); private final HttpGenerator generator = new HttpGenerator(); private boolean shutdown; diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/ProtocolHttpUpgrader.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/ProtocolHttpUpgrader.java index 6487c35f582..688b424ac18 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/ProtocolHttpUpgrader.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/ProtocolHttpUpgrader.java @@ -35,8 +35,8 @@ import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Promise; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

A HttpUpgrader that upgrades to a given protocol.

@@ -47,7 +47,7 @@ import org.eclipse.jetty.util.log.Logger; */ public class ProtocolHttpUpgrader implements HttpUpgrader { - private static final Logger LOG = Log.getLogger(ProtocolHttpUpgrader.class); + private static final Logger LOG = LoggerFactory.getLogger(ProtocolHttpUpgrader.class); private final HttpDestination destination; private final String protocol; diff --git a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/ClientConnectionFactoryOverHTTP2.java b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/ClientConnectionFactoryOverHTTP2.java index 5e7a63233e0..1f17ae4bfcd 100644 --- a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/ClientConnectionFactoryOverHTTP2.java +++ b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/ClientConnectionFactoryOverHTTP2.java @@ -87,6 +87,9 @@ public class ClientConnectionFactoryOverHTTP2 extends ContainerLifeCycle impleme // handle the HTTP/2 response to the upgrade request. promise.succeeded(connection); connection.upgrade(context); + // The connection can be used only after the upgrade that + // creates stream #1 corresponding to the HTTP/1.1 upgrade + // request, otherwise other requests can steal id #1. destination.accept(connection); } 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 8f33a65626d..b3aeacaa3de 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 @@ -37,12 +37,12 @@ import org.eclipse.jetty.http2.frames.DataFrame; import org.eclipse.jetty.http2.frames.HeadersFrame; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Promise; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HttpSenderOverHTTP2 extends HttpSender { - private static final Logger LOG = Log.getLogger(HttpSenderOverHTTP2.class); + private static final Logger LOG = LoggerFactory.getLogger(HttpSenderOverHTTP2.class); public HttpSenderOverHTTP2(HttpChannelOverHTTP2 channel) {