diff --git a/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/H2ToStH1ClientDuplexHandler.java b/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/H2ToStH1ClientDuplexHandler.java index d9dea58764..21d85cca0f 100644 --- a/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/H2ToStH1ClientDuplexHandler.java +++ b/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/H2ToStH1ClientDuplexHandler.java @@ -23,6 +23,7 @@ import io.servicetalk.http.api.HttpRequestMetaData; import io.servicetalk.http.api.HttpRequestMethod; import io.servicetalk.http.api.HttpResponseStatus; +import io.servicetalk.http.api.HttpScheme; import io.servicetalk.transport.api.ConnectionObserver.StreamObserver; import io.servicetalk.transport.netty.internal.CloseHandler; import io.servicetalk.transport.netty.internal.DefaultNettyConnection.CancelWriteUserEvent; @@ -30,7 +31,6 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; -import io.netty.handler.codec.http.HttpScheme; import io.netty.handler.codec.http2.Http2DataFrame; import io.netty.handler.codec.http2.Http2Headers; import io.netty.handler.codec.http2.Http2HeadersFrame; @@ -63,7 +63,7 @@ final class H2ToStH1ClientDuplexHandler extends AbstractH2DuplexHandler { H2ToStH1ClientDuplexHandler(boolean sslEnabled, BufferAllocator allocator, HttpHeadersFactory headersFactory, CloseHandler closeHandler, StreamObserver observer) { super(allocator, headersFactory, closeHandler, observer); - this.scheme = sslEnabled ? HttpScheme.HTTPS : HttpScheme.HTTP; + this.scheme = sslEnabled ? HttpScheme.https() : HttpScheme.http(); } @Override diff --git a/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/H2SchemeTest.java b/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/H2SchemeTest.java index 1a5697e59a..6611313115 100644 --- a/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/H2SchemeTest.java +++ b/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/H2SchemeTest.java @@ -16,6 +16,7 @@ package io.servicetalk.http.netty; import io.servicetalk.http.api.BlockingHttpClient; +import io.servicetalk.http.api.HttpScheme; import io.servicetalk.http.api.SingleAddressHttpClientBuilder; import io.servicetalk.http.netty.H2PriorKnowledgeFeatureParityTest.EchoHttp2Handler; import io.servicetalk.tcp.netty.internal.TcpServerConfig; @@ -32,7 +33,6 @@ import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; -import io.netty.handler.codec.http.HttpScheme; import io.netty.handler.codec.http2.Http2FrameCodecBuilder; import io.netty.handler.codec.http2.Http2Headers; import io.netty.handler.codec.http2.Http2HeadersFrame; @@ -47,8 +47,6 @@ import java.net.InetSocketAddress; import javax.annotation.Nullable; -import static io.netty.handler.codec.http.HttpScheme.HTTP; -import static io.netty.handler.codec.http.HttpScheme.HTTPS; import static io.servicetalk.http.api.HttpResponseStatus.OK; import static io.servicetalk.http.netty.BuilderUtils.newClientBuilder; import static io.servicetalk.http.netty.HttpProtocol.HTTP_1; @@ -111,7 +109,8 @@ protected void initChannel(final Channel parentChannel) { @Override protected void initChannel(final Http2StreamChannel streamChannel) { streamChannel.pipeline() - .addLast(new SchemeValidatorHandler(sslContext != null ? HTTPS : HTTP)); + .addLast(new SchemeValidatorHandler( + sslContext != null ? HttpScheme.https() : HttpScheme.http())); streamChannel.pipeline().addLast(new EchoHttp2Handler()); } })); @@ -158,7 +157,7 @@ private SchemeValidatorHandler(final HttpScheme expectedScheme) { public void channelRead(final ChannelHandlerContext ctx, final Object msg) { if (msg instanceof Http2HeadersFrame) { Http2Headers headers = ((Http2HeadersFrame) msg).headers(); - if (!expectedScheme.name().equals(headers.scheme())) { + if (!expectedScheme.name().contentEquals(headers.scheme())) { throw new IllegalArgumentException("Unexpected :scheme received: " + headers.scheme() + ", expected: " + expectedScheme); }