List of usage examples for io.netty.handler.codec.http2 Http2Settings pushEnabled
public Http2Settings pushEnabled(boolean enabled)
From source file:com.netty.grpc.proxy.demo.handler.GrpcProxyBackendHandler.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) { // // ww w.j a v a 2 s . c om Http2Settings settings = new Http2Settings(); settings.initialWindowSize(DEFAULT_FLOW_CONTROL_WINDOW); settings.pushEnabled(false); settings.maxConcurrentStreams(0); ByteBuf preface = Http2CodecUtil.connectionPrefaceBuf().retainedDuplicate(); ctx.write(preface); writer.writeSettings(ctx, settings, ctx.newPromise()); writer.writeWindowUpdate(ctx, 0, 983041, ctx.newPromise()); ctx.flush(); ctx.read(); }
From source file:io.grpc.netty.FixedHttp2ConnectionDecoder.java
License:Apache License
@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()); }/*from w w w.j a v a 2 s .c o m*/ return settings; }
From source file:io.grpc.netty.NettyClientHandler.java
License:Apache License
@VisibleForTesting static NettyClientHandler newHandler(final Http2Connection connection, Http2FrameReader frameReader, Http2FrameWriter frameWriter, ClientTransportLifecycleManager lifecycleManager, KeepAliveManager keepAliveManager, int flowControlWindow, int maxHeaderListSize, Supplier<Stopwatch> stopwatchFactory, Runnable tooManyPingsRunnable, TransportTracer transportTracer, Attributes eagAttributes, String authority) { Preconditions.checkNotNull(connection, "connection"); Preconditions.checkNotNull(frameReader, "frameReader"); Preconditions.checkNotNull(lifecycleManager, "lifecycleManager"); Preconditions.checkArgument(flowControlWindow > 0, "flowControlWindow must be positive"); Preconditions.checkArgument(maxHeaderListSize > 0, "maxHeaderListSize must be positive"); Preconditions.checkNotNull(stopwatchFactory, "stopwatchFactory"); Preconditions.checkNotNull(tooManyPingsRunnable, "tooManyPingsRunnable"); Preconditions.checkNotNull(eagAttributes, "eagAttributes"); Preconditions.checkNotNull(authority, "authority"); Http2FrameLogger frameLogger = new Http2FrameLogger(LogLevel.DEBUG, NettyClientHandler.class); frameReader = new Http2InboundFrameLogger(frameReader, frameLogger); frameWriter = new Http2OutboundFrameLogger(frameWriter, frameLogger); StreamBufferingEncoder encoder = new StreamBufferingEncoder( new DefaultHttp2ConnectionEncoder(connection, frameWriter)); // Create the local flow controller configured to auto-refill the connection window. connection.local()//from w w w.ja va 2 s.c o m .flowController(new DefaultHttp2LocalFlowController(connection, DEFAULT_WINDOW_UPDATE_RATIO, true)); Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(connection, encoder, frameReader); transportTracer.setFlowControlWindowReader(new TransportTracer.FlowControlReader() { final Http2FlowController local = connection.local().flowController(); final Http2FlowController remote = connection.remote().flowController(); @Override public TransportTracer.FlowControlWindows read() { return new TransportTracer.FlowControlWindows(local.windowSize(connection.connectionStream()), remote.windowSize(connection.connectionStream())); } }); Http2Settings settings = new Http2Settings(); settings.pushEnabled(false); settings.initialWindowSize(flowControlWindow); settings.maxConcurrentStreams(0); settings.maxHeaderListSize(maxHeaderListSize); return new NettyClientHandler(decoder, encoder, settings, lifecycleManager, keepAliveManager, stopwatchFactory, tooManyPingsRunnable, transportTracer, eagAttributes, authority); }
From source file:io.vertx.core.http.impl.HttpUtils.java
License:Open Source License
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()); }//from w ww. j a v a 2s . c o m 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); }); } } }
From source file:io.vertx.core.http.impl.HttpUtils.java
License:Open Source License
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); });/*w w w . java2 s . c o m*/ } return converted; }
From source file:jmeter.plugins.http2.sampler.Http2ClientInitializer.java
License:Apache License
private Http2FrameWriter frameWriter() { // Set initial SETTINGS Http2Settings settings = new Http2Settings(); settings.pushEnabled(false); settings.maxConcurrentStreams(100);/*from www . j av a 2s . c o m*/ return new Http2OutboundFrameLogger(new CustomHttp2FrameWriter(settings), logger); }