< prev index next >

src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2ClientImpl.java

Print this page

        

*** 34,43 **** --- 34,45 ---- import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CompletableFuture; + + import jdk.incubator.http.internal.common.Log; import jdk.incubator.http.internal.common.MinimalFuture; import jdk.incubator.http.internal.common.Utils; import jdk.incubator.http.internal.frame.SettingsFrame; import static jdk.incubator.http.internal.frame.SettingsFrame.INITIAL_WINDOW_SIZE; import static jdk.incubator.http.internal.frame.SettingsFrame.ENABLE_PUSH;
*** 76,89 **** } waiters.add(cf); } } - // boolean haveConnectionFor(URI uri, InetSocketAddress proxy) { - // return connections.containsKey(Http2Connection.keyFor(uri,proxy)); - // } - /** * If a https request then async waits until a connection is opened. * Returns null if the request is 'http' as a different (upgrade) * mechanism is used. * --- 78,87 ----
*** 186,205 **** return encoder.encodeToString(settings); } private static final int K = 1024; SettingsFrame getClientSettings() { SettingsFrame frame = new SettingsFrame(); ! frame.setParameter(HEADER_TABLE_SIZE, Utils.getIntegerNetProperty( ! "jdk.httpclient.hpack.maxheadertablesize", 16 * K)); ! frame.setParameter(ENABLE_PUSH, Utils.getIntegerNetProperty( ! "jdk.httpclient.enablepush", 1)); ! frame.setParameter(MAX_CONCURRENT_STREAMS, Utils.getIntegerNetProperty( ! "jdk.httpclient.maxstreams", 16)); ! frame.setParameter(INITIAL_WINDOW_SIZE, Utils.getIntegerNetProperty( ! "jdk.httpclient.windowsize", 64 * K - 1)); ! frame.setParameter(MAX_FRAME_SIZE, Utils.getIntegerNetProperty( ! "jdk.httpclient.maxframesize", 16 * K)); return frame; } } --- 184,249 ---- return encoder.encodeToString(settings); } private static final int K = 1024; + private static int getParameter(String property, int min, int max, int defaultValue) { + int value = Utils.getIntegerNetProperty(property, defaultValue); + // use default value if misconfigured + if (value < min || value > max) { + Log.logError("Property value for {0}={1} not in [{2}..{3}]: " + + "using default={4}", property, value, min, max, defaultValue); + value = defaultValue; + } + return value; + } + + // used for the connection window, to have a connection window size + // bigger than the initial stream window size. + int getConnectionWindowSize(SettingsFrame clientSettings) { + // Maximum size is 2^31-1. Don't allow window size to be less + // than the stream window size. HTTP/2 specify a default of 64 * K -1, + // but we use 2^26 by default for better performance. + int streamWindow = clientSettings.getParameter(INITIAL_WINDOW_SIZE); + + // The default is the max between the stream window size + // and the connection window size. + int defaultValue = Math.min(Integer.MAX_VALUE, + Math.max(streamWindow, K*K*32)); + + return getParameter( + "jdk.httpclient.connectionWindowSize", + streamWindow, Integer.MAX_VALUE, defaultValue); + } + SettingsFrame getClientSettings() { SettingsFrame frame = new SettingsFrame(); ! // default defined for HTTP/2 is 4 K, we use 16 K. ! frame.setParameter(HEADER_TABLE_SIZE, getParameter( ! "jdk.httpclient.hpack.maxheadertablesize", ! 0, Integer.MAX_VALUE, 16 * K)); ! // O: does not accept push streams. 1: accepts push streams. ! frame.setParameter(ENABLE_PUSH, getParameter( ! "jdk.httpclient.enablepush", ! 0, 1, 1)); ! // HTTP/2 recommends to set the number of concurrent streams ! // no lower than 100. We use 100. 0 means no stream would be ! // accepted. That would render the client to be non functional, ! // so we won't let 0 be configured for our Http2ClientImpl. ! frame.setParameter(MAX_CONCURRENT_STREAMS, getParameter( ! "jdk.httpclient.maxstreams", ! 1, Integer.MAX_VALUE, 100)); ! // Maximum size is 2^31-1. Don't allow window size to be less ! // than the minimum frame size as this is likely to be a ! // configuration error. HTTP/2 specify a default of 64 * K -1, ! // but we use 16 M for better performance. ! frame.setParameter(INITIAL_WINDOW_SIZE, getParameter( ! "jdk.httpclient.windowsize", ! 16 * K, Integer.MAX_VALUE, 16*K*K)); ! // HTTP/2 specify a minimum size of 16 K, a maximum size of 2^24-1, ! // and a default of 16 K. We use 16 K as default. ! frame.setParameter(MAX_FRAME_SIZE, getParameter( ! "jdk.httpclient.maxframesize", ! 16 * K, 16 * K * K -1, 16 * K)); return frame; } }
< prev index next >