@Override final void onHttp2Frame(ChannelHandlerContext ctx, Http2Frame frame) { if (frame instanceof Http2StreamFrame) { Http2StreamFrame streamFrame = (Http2StreamFrame) frame; ((Http2MultiplexCodecStream) streamFrame.stream()).channel.fireChildRead(streamFrame); } else if (frame instanceof Http2GoAwayFrame) { onHttp2GoAwayFrame(ctx, (Http2GoAwayFrame) frame); // Allow other handlers to act on GOAWAY frame ctx.fireChannelRead(frame); } else if (frame instanceof Http2SettingsFrame) { Http2Settings settings = ((Http2SettingsFrame) frame).settings(); if (settings.initialWindowSize() != null) { initialOutboundStreamWindow = settings.initialWindowSize(); } // Allow other handlers to act on SETTINGS frame ctx.fireChannelRead(frame); } else { // Send any other frames down the pipeline ctx.fireChannelRead(frame); } }
private void configureHttp2(ChannelPipeline pipeline) { // setup the initial stream settings for the server to use. Http2Settings settings = new Http2Settings() .maxConcurrentStreams(maxConcurrentStreams) .initialWindowSize(initialWindowSize) .headerTableSize(maxHeaderTableSize) .maxHeaderListSize(maxHeaderListSize); Http2MultiplexCodec multiplexCodec = Http2MultiplexCodecBuilder .forServer(http2StreamHandler) .frameLogger(FRAME_LOGGER) .initialSettings(settings) .validateHeaders(true) .build(); pipeline.replace("codec_placeholder", HTTP_CODEC_HANDLER_NAME, multiplexCodec); // Need to pass the connection to our handler later, so store it on channel now. Http2Connection connection = multiplexCodec.connection(); pipeline.channel().attr(H2_CONN_KEY).set(connection); }
private Http2Settings http2Settings() { final Http2Settings settings = new Http2Settings(); final int initialWindowSize = clientFactory.http2InitialStreamWindowSize(); if (initialWindowSize != DEFAULT_WINDOW_SIZE) { settings.initialWindowSize(initialWindowSize); } final int maxFrameSize = clientFactory.http2MaxFrameSize(); if (maxFrameSize != DEFAULT_MAX_FRAME_SIZE) { settings.maxFrameSize(maxFrameSize); } settings.maxHeaderListSize(clientFactory.http2MaxHeaderListSize()); return settings; }
private Http2Settings http2Settings() { final Http2Settings settings = new Http2Settings(); final int initialWindowSize = config.http2InitialStreamWindowSize(); if (initialWindowSize != Http2CodecUtil.DEFAULT_WINDOW_SIZE) { settings.initialWindowSize(initialWindowSize); } final int maxFrameSize = config.http2MaxFrameSize(); if (maxFrameSize != Http2CodecUtil.DEFAULT_MAX_FRAME_SIZE) { settings.maxFrameSize(maxFrameSize); } // Not using the value greater than 2^31-1 because some HTTP/2 client implementations use a signed // 32-bit integer to represent an HTTP/2 SETTINGS parameter value. settings.maxConcurrentStreams(Math.min(config.http2MaxStreamsPerConnection(), Integer.MAX_VALUE)); settings.maxHeaderListSize(config.http2MaxHeaderListSize()); return settings; }
public static Http2Settings fromVertxSettings(io.vertx.core.http.Http2Settings settings) { Http2Settings converted = new Http2Settings(); converted.pushEnabled(settings.isPushEnabled()); converted.maxFrameSize(settings.getMaxFrameSize()); converted.initialWindowSize(settings.getInitialWindowSize()); converted.headerTableSize(settings.getHeaderTableSize()); converted.maxConcurrentStreams(settings.getMaxConcurrentStreams()); converted.maxHeaderListSize(settings.getMaxHeaderListSize()); if (settings.getExtraSettings() != null) { settings.getExtraSettings().forEach((key, value) -> { converted.put((char)(int)key, value); }); } return converted; }
Http2FrameCodec(Http2ConnectionEncoder encoder, Http2ConnectionDecoder decoder, Http2Settings initialSettings) { super(decoder, encoder, initialSettings); decoder.frameListener(new FrameListener()); connection().addListener(new ConnectionListener()); connection().remote().flowController().listener(new Http2RemoteFlowControllerListener()); streamKey = connection().newKey(); upgradeKey = connection().newKey(); initialFlowControlWindowSize = initialSettings.initialWindowSize(); }
Http2FrameCodec(Http2ConnectionEncoder encoder, Http2ConnectionDecoder decoder, Http2Settings initialSettings) { super(decoder, encoder, initialSettings); decoder.frameListener(new FrameListener()); connection().addListener(new ConnectionListener()); connection().remote().flowController().listener(new Http2RemoteFlowControllerListener()); streamKey = connection().newKey(); upgradeKey = connection().newKey(); initialFlowControlWindowSize = initialSettings.initialWindowSize(); }
private void configureHttp2(ChannelPipeline pipeline) { // setup the initial stream settings for the server to use. Http2Settings settings = new Http2Settings() .maxConcurrentStreams(maxConcurrentStreams) .initialWindowSize(initialWindowSize) .headerTableSize(maxHeaderTableSize) .maxHeaderListSize(maxHeaderListSize); Http2MultiplexCodec multiplexCodec = Http2MultiplexCodecBuilder .forServer(http2StreamHandler) .frameLogger(FRAME_LOGGER) .initialSettings(settings) .validateHeaders(true) .build(); pipeline.replace("codec_placeholder", HTTP_CODEC_HANDLER_NAME, multiplexCodec); // Need to pass the connection to our handler later, so store it on channel now. Http2Connection connection = multiplexCodec.connection(); pipeline.channel().attr(H2_CONN_KEY).set(connection); }
public static void fromVertxInitialSettings(boolean server, io.vertx.core.http.Http2Settings vertxSettings, Http2Settings nettySettings) { if (vertxSettings != null) { if (!server && vertxSettings.isPushEnabled() != DEFAULT_ENABLE_PUSH) { nettySettings.pushEnabled(vertxSettings.isPushEnabled()); } if (vertxSettings.getHeaderTableSize() != DEFAULT_HEADER_TABLE_SIZE) { nettySettings.put('\u0001', (Long)vertxSettings.getHeaderTableSize()); } if (vertxSettings.getInitialWindowSize() != DEFAULT_INITIAL_WINDOW_SIZE) { nettySettings.initialWindowSize(vertxSettings.getInitialWindowSize()); } if (vertxSettings.getMaxConcurrentStreams() != DEFAULT_MAX_CONCURRENT_STREAMS) { nettySettings.maxConcurrentStreams(vertxSettings.getMaxConcurrentStreams()); } if (vertxSettings.getMaxFrameSize() != DEFAULT_MAX_FRAME_SIZE) { nettySettings.maxFrameSize(vertxSettings.getMaxFrameSize()); } if (vertxSettings.getMaxHeaderListSize() != DEFAULT_MAX_HEADER_LIST_SIZE) { nettySettings.maxHeaderListSize(vertxSettings.getMaxHeaderListSize()); } Map<Integer, Long> extraSettings = vertxSettings.getExtraSettings(); if (extraSettings != null) { extraSettings.forEach((code, setting) -> { nettySettings.put((char)(int)code, setting); }); } } }
Integer initialWindowSize = settings.initialWindowSize(); if (initialWindowSize != null) { flowController().initialWindowSize(initialWindowSize);
converted.setMaxFrameSize(maxFrameSize); Integer initialWindowSize = settings.initialWindowSize(); if (initialWindowSize != null) { converted.setInitialWindowSize(initialWindowSize);
Integer initialWindowSize = settings.initialWindowSize(); if (initialWindowSize != null) { flowController().initialWindowSize(initialWindowSize);
@Override public Http2Settings localSettings() { Http2Settings settings = new Http2Settings(); Http2FrameReader.Configuration config = frameReader.configuration(); Http2HeadersDecoder.Configuration headersConfig = config.headersConfiguration(); Http2FrameSizePolicy frameSizePolicy = config.frameSizePolicy(); settings.initialWindowSize(flowController().initialWindowSize()); settings.maxConcurrentStreams(connection.remote().maxActiveStreams()); settings.headerTableSize(headersConfig.maxHeaderTableSize()); settings.maxFrameSize(frameSizePolicy.maxFrameSize()); settings.maxHeaderListSize(headersConfig.maxHeaderListSize()); if (!connection.isServer()) { // Only set the pushEnabled flag if this is a client endpoint. settings.pushEnabled(connection.local().allowPushTo()); } return settings; }
Http2FrameCodec(Http2ConnectionEncoder encoder, Http2ConnectionDecoder decoder, Http2Settings initialSettings) { super(decoder, encoder, initialSettings); decoder.frameListener(new FrameListener()); connection().addListener(new ConnectionListener()); connection().remote().flowController().listener(new Http2RemoteFlowControllerListener()); streamKey = connection().newKey(); upgradeKey = connection().newKey(); initialFlowControlWindowSize = initialSettings.initialWindowSize(); }
public static Http2Settings fromVertxSettings(io.vertx.core.http.Http2Settings settings) { Http2Settings converted = new Http2Settings(); converted.pushEnabled(settings.isPushEnabled()); converted.maxFrameSize(settings.getMaxFrameSize()); converted.initialWindowSize(settings.getInitialWindowSize()); converted.headerTableSize(settings.getHeaderTableSize()); converted.maxConcurrentStreams(settings.getMaxConcurrentStreams()); converted.maxHeaderListSize(settings.getMaxHeaderListSize()); if (settings.getExtraSettings() != null) { settings.getExtraSettings().forEach((key, value) -> { converted.put((char)(int)key, value); }); } return converted; }
public static void fromVertxInitialSettings(boolean server, io.vertx.core.http.Http2Settings vertxSettings, Http2Settings nettySettings) { if (vertxSettings != null) { if (!server && vertxSettings.isPushEnabled() != DEFAULT_ENABLE_PUSH) { nettySettings.pushEnabled(vertxSettings.isPushEnabled()); } if (vertxSettings.getHeaderTableSize() != DEFAULT_HEADER_TABLE_SIZE) { nettySettings.put('\u0001', (Long)vertxSettings.getHeaderTableSize()); } if (vertxSettings.getInitialWindowSize() != DEFAULT_INITIAL_WINDOW_SIZE) { nettySettings.initialWindowSize(vertxSettings.getInitialWindowSize()); } if (vertxSettings.getMaxConcurrentStreams() != DEFAULT_MAX_CONCURRENT_STREAMS) { nettySettings.maxConcurrentStreams(vertxSettings.getMaxConcurrentStreams()); } if (vertxSettings.getMaxFrameSize() != DEFAULT_MAX_FRAME_SIZE) { nettySettings.maxFrameSize(vertxSettings.getMaxFrameSize()); } if (vertxSettings.getMaxHeaderListSize() != DEFAULT_MAX_HEADER_LIST_SIZE) { nettySettings.maxHeaderListSize(vertxSettings.getMaxHeaderListSize()); } Map<Integer, Long> extraSettings = vertxSettings.getExtraSettings(); if (extraSettings != null) { extraSettings.forEach((code, setting) -> { nettySettings.put((char)(int)code, setting); }); } } }
converted.setMaxFrameSize(maxFrameSize); Integer initialWindowSize = settings.initialWindowSize(); if (initialWindowSize != null) { converted.setInitialWindowSize(initialWindowSize);
@Override protected NettyHttp2Handler build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings) throws Exception { NettyHttp2Handler handler = new NettyHttp2Handler(decoder, encoder, initialSettings, heartbeatTimeoutThreshold); frameListener(handler); initialSettings().pushEnabled(true); initialSettings().initialWindowSize(1073741824); initialSettings().maxFrameSize(1024 * 1024); return handler; }
Http2FrameCodec(Http2ConnectionEncoder encoder, Http2ConnectionDecoder decoder, Http2Settings initialSettings) { super(decoder, encoder, initialSettings); decoder.frameListener(new FrameListener()); connection().addListener(new ConnectionListener()); connection().remote().flowController().listener(new Http2RemoteFlowControllerListener()); streamKey = connection().newKey(); upgradeKey = connection().newKey(); initialFlowControlWindowSize = initialSettings.initialWindowSize(); }
Http2FrameCodec(Http2ConnectionEncoder encoder, Http2ConnectionDecoder decoder, Http2Settings initialSettings) { super(decoder, encoder, initialSettings); decoder.frameListener(new FrameListener()); connection().addListener(new ConnectionListener()); connection().remote().flowController().listener(new Http2RemoteFlowControllerListener()); streamKey = connection().newKey(); upgradeKey = connection().newKey(); initialFlowControlWindowSize = initialSettings.initialWindowSize(); }