+ * Note this doesn't necessarily provide {@link H2ProtocolConfig#initialSettings()} that corresponds to + * default values as described in + * HTTP/2 Settings. Some identifiers + * maybe overridden for safety or performance reasons and are subject to change. For more control use {@link #h2()}. * * @return {@link H2ProtocolConfig} with the default configuration for * HTTP/2 @@ -62,6 +69,12 @@ public static H2ProtocolConfig h2Default() { /** * Returns a builder for {@link H2ProtocolConfig}. + *
+ * Note this doesn't necessarily provide {@link H2ProtocolConfig#initialSettings()} that corresponds to + * default values as described in + * HTTP/2 Settings. Some identifiers + * maybe overridden for safety or performance reasons and are subject to change. For more control use + * {@link H2ProtocolConfigBuilder#initialSettings(Map)}. * * @return {@link H2ProtocolConfigBuilder} */ diff --git a/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/OptimizedHttp2FrameCodecBuilder.java b/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/OptimizedHttp2FrameCodecBuilder.java index 193c7ada6f..7c6786dcbf 100644 --- a/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/OptimizedHttp2FrameCodecBuilder.java +++ b/servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/OptimizedHttp2FrameCodecBuilder.java @@ -28,7 +28,7 @@ import java.lang.invoke.MethodHandles; import javax.annotation.Nullable; -import static io.servicetalk.utils.internal.PlatformDependent.throwException; +import static io.servicetalk.utils.internal.ThrowableUtils.throwException; import static java.lang.invoke.MethodType.methodType; /** @@ -61,14 +61,18 @@ final class OptimizedHttp2FrameCodecBuilder extends Http2FrameCodecBuilder { } private final boolean server; + private final int flowControlQuantum; /** * Creates a new instance. * * @param server {@code true} if for server, {@code false} otherwise + * @param flowControlQuantum a hint on the number of bytes that the flow controller will attempt to give to a + * stream for each allocation. */ - OptimizedHttp2FrameCodecBuilder(final boolean server) { + OptimizedHttp2FrameCodecBuilder(final boolean server, final int flowControlQuantum) { this.server = server; + this.flowControlQuantum = flowControlQuantum; disableFlushPreface(FLUSH_PREFACE, this); } @@ -80,8 +84,9 @@ public boolean isServer() { @Override public Http2FrameCodec build() { final DefaultHttp2Connection connection = new DefaultHttp2Connection(isServer(), maxReservedStreams()); - connection.remote().flowController(new DefaultHttp2RemoteFlowController(connection, - new UniformStreamByteDistributor(connection))); + UniformStreamByteDistributor distributor = new UniformStreamByteDistributor(connection); + distributor.minAllocationChunk(flowControlQuantum); + connection.remote().flowController(new DefaultHttp2RemoteFlowController(connection, distributor)); connection(connection); return super.build(); }