[#705] Fix SpdyOrHttpChooser
This commit is contained in:
parent
8c659331e3
commit
87ba8cb4b0
@ -18,6 +18,7 @@ package io.netty.handler.codec.spdy;
|
|||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerAdapter;
|
import io.netty.channel.ChannelHandlerAdapter;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@ -63,22 +64,24 @@ public abstract class SpdyOrHttpChooser extends ChannelHandlerAdapter implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ByteBuf newInboundBuffer(ChannelHandlerContext ctx) throws Exception {
|
public ByteBuf newInboundBuffer(ChannelHandlerContext ctx) throws Exception {
|
||||||
return ctx.nextInboundByteBuffer();
|
return Unpooled.buffer();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
|
||||||
initPipeline(ctx);
|
|
||||||
ctx.fireChannelActive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
|
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
|
||||||
initPipeline(ctx);
|
if (initPipeline(ctx)) {
|
||||||
|
ctx.nextInboundByteBuffer().writeBytes(ctx.inboundByteBuffer());
|
||||||
|
|
||||||
|
// When we reached here we can remove this handler as its now clear what protocol we want to use
|
||||||
|
// from this point on.
|
||||||
|
ctx.pipeline().remove(this);
|
||||||
|
|
||||||
ctx.fireInboundBufferUpdated();
|
ctx.fireInboundBufferUpdated();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initPipeline(ChannelHandlerContext ctx) {
|
private boolean initPipeline(ChannelHandlerContext ctx) {
|
||||||
// Get the SslHandler from the ChannelPipeline so we can obtain the SslEngine from it.
|
// Get the SslHandler from the ChannelPipeline so we can obtain the SslEngine from it.
|
||||||
SslHandler handler = ctx.pipeline().get(SslHandler.class);
|
SslHandler handler = ctx.pipeline().get(SslHandler.class);
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
@ -91,7 +94,7 @@ public abstract class SpdyOrHttpChooser extends ChannelHandlerAdapter implements
|
|||||||
switch (protocol) {
|
switch (protocol) {
|
||||||
case None:
|
case None:
|
||||||
// Not done with choosing the protocol, so just return here for now,
|
// Not done with choosing the protocol, so just return here for now,
|
||||||
return;
|
return false;
|
||||||
case SpdyVersion2:
|
case SpdyVersion2:
|
||||||
addSpdyHandlers(ctx, 2);
|
addSpdyHandlers(ctx, 2);
|
||||||
break;
|
break;
|
||||||
@ -105,9 +108,7 @@ public abstract class SpdyOrHttpChooser extends ChannelHandlerAdapter implements
|
|||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unknown SelectedProtocol");
|
throw new IllegalStateException("Unknown SelectedProtocol");
|
||||||
}
|
}
|
||||||
// When we reached here we can remove this handler as its now clear what protocol we want to use
|
return true;
|
||||||
// from this point on.
|
|
||||||
pipeline.remove(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user