Java 类io.netty.handler.codec.spdy.SpdyVersion 实例源码
项目:JavaAyo
文件:SpdyOrHttpHandler.java
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
if (ApplicationProtocolNames.SPDY_3_1.equals(protocol)) {
configureSpdy(ctx, SpdyVersion.SPDY_3_1);
return;
}
if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
configureHttp1(ctx);
return;
}
throw new IllegalStateException("unknown protocol: " + protocol);
}
项目:JavaAyo
文件:SpdyOrHttpHandler.java
private static void configureSpdy(ChannelHandlerContext ctx, SpdyVersion version) throws Exception {
ChannelPipeline p = ctx.pipeline();
p.addLast(new SpdyFrameCodec(version));
p.addLast(new SpdySessionHandler(version, true));
p.addLast(new SpdyHttpEncoder(version));
p.addLast(new SpdyHttpDecoder(version, MAX_CONTENT_LENGTH));
p.addLast(new SpdyHttpResponseStreamIdHandler());
p.addLast(new SpdyServerHandler());
}
项目:netty4study
文件:SocketSpdyEchoTest.java
@Test(timeout = 15000)
public void testSpdyEcho() throws Throwable {
version = SpdyVersion.SPDY_3;
logger.info("Testing against SPDY v3");
run();
version = SpdyVersion.SPDY_3_1;
logger.info("Testing against SPDY v3.1");
run();
}
项目:netty-netty-5.0.0.Alpha1
文件:SocketSpdyEchoTest.java
@Test(timeout = 15000)
public void testSpdyEcho() throws Throwable {
version = SpdyVersion.SPDY_3;
logger.info("Testing against SPDY v3");
run();
version = SpdyVersion.SPDY_3_1;
logger.info("Testing against SPDY v3.1");
run();
}
项目:netty4.0.27Learn
文件:SocketSpdyEchoTest.java
public void testSpdyEcho(ServerBootstrap sb, Bootstrap cb) throws Throwable {
logger.info("Testing against SPDY v3.1");
testSpdyEcho(sb, cb, SpdyVersion.SPDY_3_1, true);
}
项目:netty4.0.27Learn
文件:SocketSpdyEchoTest.java
public void testSpdyEchoNotAutoRead(ServerBootstrap sb, Bootstrap cb) throws Throwable {
logger.info("Testing against SPDY v3.1");
testSpdyEcho(sb, cb, SpdyVersion.SPDY_3_1, false);
}
项目:netty4.0.27Learn
文件:SocketSpdyEchoTest.java
private static void testSpdyEcho(
ServerBootstrap sb, Bootstrap cb, final SpdyVersion version, boolean autoRead) throws Throwable {
ByteBuf frames;
switch (version) {
case SPDY_3_1:
frames = createFrames(3);
break;
default:
throw new IllegalArgumentException("unknown version");
}
final SpdyEchoTestServerHandler sh = new SpdyEchoTestServerHandler(autoRead);
final SpdyEchoTestClientHandler ch = new SpdyEchoTestClientHandler(frames.copy(), autoRead);
sb.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel channel) throws Exception {
channel.pipeline().addLast(
new SpdyFrameCodec(version),
sh);
}
});
cb.handler(ch);
Channel sc = sb.localAddress(0).bind().sync().channel();
int port = ((InetSocketAddress) sc.localAddress()).getPort();
Channel cc = cb.remoteAddress(NetUtil.LOCALHOST, port).connect().sync().channel();
cc.writeAndFlush(frames);
while (ch.counter < frames.writerIndex() - ignoredBytes) {
if (sh.exception.get() != null) {
break;
}
if (ch.exception.get() != null) {
break;
}
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// Ignore.
}
}
if (sh.exception.get() != null && !(sh.exception.get() instanceof IOException)) {
throw sh.exception.get();
}
if (ch.exception.get() != null && !(ch.exception.get() instanceof IOException)) {
throw ch.exception.get();
}
if (sh.exception.get() != null) {
throw sh.exception.get();
}
if (ch.exception.get() != null) {
throw ch.exception.get();
}
}