diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyOrHttpChooser.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyOrHttpChooser.java index e92f390238..c14a0d669b 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyOrHttpChooser.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyOrHttpChooser.java @@ -15,24 +15,26 @@ */ package io.netty.handler.codec.spdy; +import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandler; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelPipeline; +import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpRequestDecoder; import io.netty.handler.codec.http.HttpResponseEncoder; import io.netty.handler.ssl.SslHandler; import javax.net.ssl.SSLEngine; +import java.util.List; /** * {@link ChannelInboundHandler} which is responsible to setup the {@link ChannelPipeline} either for * HTTP or SPDY. This offers an easy way for users to support both at the same time while not care to * much about the low-level details. */ -public abstract class SpdyOrHttpChooser extends ChannelInboundHandlerAdapter { +public abstract class SpdyOrHttpChooser extends ByteToMessageDecoder { // TODO: Replace with generic NPN handler @@ -60,13 +62,11 @@ public abstract class SpdyOrHttpChooser extends ChannelInboundHandlerAdapter { protected abstract SelectedProtocol getProtocol(SSLEngine engine); @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { if (initPipeline(ctx)) { // When we reached here we can remove this handler as its now clear what protocol we want to use - // from this point on. + // from this point on. This will also take care of forward all messages. ctx.pipeline().remove(this); - - ctx.fireChannelRead(msg); } } @@ -136,7 +136,7 @@ public abstract class SpdyOrHttpChooser extends ChannelInboundHandlerAdapter { * when the {@link SelectedProtocol} was {@link SelectedProtocol#SPDY_2} or * {@link SelectedProtocol#SPDY_3}. * - * Bye default this getMethod will just delecate to {@link #createHttpRequestHandlerForHttp()}, but + * By default this getMethod will just delecate to {@link #createHttpRequestHandlerForHttp()}, but * sub-classes may override this to change the behaviour. */ protected ChannelInboundHandler createHttpRequestHandlerForSpdy() {