@Override public synchronized void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) { Long v = settings.maxConcurrentStreams(); if (v != null) { maxConcurrentStreams = v; } super.onSettingsRead(ctx, settings); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof Http2Settings) { final Long maxConcurrentStreams = ((Http2Settings) msg).maxConcurrentStreams(); if (maxConcurrentStreams != null) { maxUnfinishedResponses = maxConcurrentStreams > Integer.MAX_VALUE ? Integer.MAX_VALUE : maxConcurrentStreams.intValue(); } else { maxUnfinishedResponses = Integer.MAX_VALUE; } return; } // Handle an unexpected message by raising an exception with debugging information. try { final String typeInfo; if (msg instanceof ByteBuf) { typeInfo = msg + " HexDump: " + ByteBufUtil.hexDump((ByteBuf) msg); } else { typeInfo = String.valueOf(msg); } throw new IllegalStateException("unexpected message type: " + typeInfo); } finally { ReferenceCountUtil.release(msg); } }
@Override public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) { boolean changed; Handler<io.vertx.core.http.Http2Settings> handler; synchronized (this) { Long val = settings.maxConcurrentStreams(); if (val != null) { if (remoteSettings != null) { changed = val != maxConcurrentStreams; } else { changed = false; } maxConcurrentStreams = val; } else { changed = false; } remoteSettings = settings; handler = remoteSettingsHandler; } if (handler != null) { context.executeFromIO(HttpUtils.toVertxSettings(settings), handler); } if (changed) { concurrencyChanged(maxConcurrentStreams); } }
@Override protected void addHandlersToPipeline(final SSLSession sslSession, final ChannelPipeline pipeline) { pipeline.addLast(new BenchmarkApnsServerHandler.BenchmarkApnsServerHandlerBuilder() .initialSettings(Http2Settings.defaultSettings().maxConcurrentStreams(this.maxConcurrentStreams)) .build()); } }
@Override protected void addHandlersToPipeline(final SSLSession sslSession, final ChannelPipeline pipeline) throws Exception { final PushNotificationHandler pushNotificationHandler = this.handlerFactory.buildHandler(sslSession); final MockApnsServerHandler serverHandler = new MockApnsServerHandler.MockApnsServerHandlerBuilder() .pushNotificationHandler(pushNotificationHandler) .initialSettings(Http2Settings.defaultSettings().maxConcurrentStreams(this.maxConcurrentStreams)) .listener(this.listener) .build(); pipeline.addLast(serverHandler); } }
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 = 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; }
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); }); } } }
Long maxConcurrentStreams = settings.maxConcurrentStreams(); if (maxConcurrentStreams != null) { connection.local().maxActiveStreams((int) min(maxConcurrentStreams, MAX_VALUE));
converted.setPushEnabled(pushEnabled); Long maxConcurrentStreams = settings.maxConcurrentStreams(); if (maxConcurrentStreams != null) { converted.setMaxConcurrentStreams(maxConcurrentStreams);
@Override public synchronized void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) { Long v = settings.maxConcurrentStreams(); if (v != null) { maxConcurrentStreams = v; } super.onSettingsRead(ctx, settings); }
@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; }
Long maxConcurrentStreams = settings.maxConcurrentStreams(); if (maxConcurrentStreams != null) { connection.remote().maxActiveStreams((int) min(maxConcurrentStreams, MAX_VALUE));
@Override public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings settings) { boolean changed; Handler<io.vertx.core.http.Http2Settings> handler; synchronized (this) { Long val = settings.maxConcurrentStreams(); if (val != null) { if (remoteSettings != null) { changed = val != maxConcurrentStreams; } else { changed = false; } maxConcurrentStreams = val; } else { changed = false; } remoteSettings = settings; handler = remoteSettingsHandler; } if (handler != null) { context.executeFromIO(HttpUtils.toVertxSettings(settings), handler); } if (changed) { concurrencyChanged(maxConcurrentStreams); } }
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); }); } } }
@Override protected void channelRead0(ChannelHandlerContext ctx, Http2SettingsFrame msg) { Long serverMaxStreams = Optional.ofNullable(msg.settings().maxConcurrentStreams()).orElse(Long.MAX_VALUE); channel.attr(MAX_CONCURRENT_STREAMS).set(Math.min(clientMaxStreams, serverMaxStreams)); channel.attr(PROTOCOL_FUTURE).get().complete(Protocol.HTTP2); }
converted.setPushEnabled(pushEnabled); Long maxConcurrentStreams = settings.maxConcurrentStreams(); if (maxConcurrentStreams != null) { converted.setMaxConcurrentStreams(maxConcurrentStreams);