io.netty.handler.codec.http2.Http2ServerUpgradeCodec Java Examples

The following examples show how to use io.netty.handler.codec.http2.Http2ServerUpgradeCodec. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Http2ServerInitializer.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public UpgradeCodec newUpgradeCodec(CharSequence protocol) {
    if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) {
        return new Http2ServerUpgradeCodec(
                Http2MultiplexCodecBuilder.forServer(new HelloWorldHttp2Handler()).build());
    } else {
        return null;
    }
}
 
Example #2
Source File: Http2ServerInitializer.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public UpgradeCodec newUpgradeCodec(CharSequence protocol) {
    if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) {
        return new Http2ServerUpgradeCodec(new HelloWorldHttp2HandlerBuilder().build());
    } else {
        return null;
    }
}
 
Example #3
Source File: Http2ServerInitializer.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public UpgradeCodec newUpgradeCodec(CharSequence protocol) {
    if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) {
        return new Http2ServerUpgradeCodec(
                Http2FrameCodecBuilder.forServer().build(), new HelloWorldHttp2Handler());
    } else {
        return null;
    }
}
 
Example #4
Source File: Http2ServerInitializer.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public UpgradeCodec newUpgradeCodec(CharSequence protocol) {
    if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) {
        return new Http2ServerUpgradeCodec(new HelloWorldHttp2HandlerBuilder().build());
    } else {
        return null;
    }
}
 
Example #5
Source File: HttpServerConfig.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public HttpServerUpgradeHandler.UpgradeCodec newUpgradeCodec(CharSequence protocol) {
	if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) {
		return new Http2ServerUpgradeCodec(http2FrameCodec, new Http2MultiplexHandler(this));
	}
	else {
		return null;
	}
}
 
Example #6
Source File: Http2ServerInitializer.java    From netty-cookbook with Apache License 2.0 5 votes vote down vote up
/**
 * Configure the pipeline for a cleartext upgrade from HTTP to HTTP/2.
 */
private static void configureClearText(SocketChannel ch) {
    HttpServerCodec sourceCodec = new HttpServerCodec();
    HelloWorldHttp2Handler http2Handler = new HelloWorldHttp2Handler();
    HttpServerUpgradeHandler.UpgradeCodec upgradeCodec = new Http2ServerUpgradeCodec(http2Handler);
    HttpServerUpgradeHandler upgradeHandler = new HttpServerUpgradeHandler(sourceCodec, Collections.singletonList(upgradeCodec), 65536);

    ch.pipeline().addLast(sourceCodec);
    ch.pipeline().addLast(upgradeHandler);
    ch.pipeline().addLast(new UserEventLogger());
}