/** * Sets the {@code SETTINGS_ENABLE_PUSH} value. */ public Http2Settings pushEnabled(boolean enabled) { put(SETTINGS_ENABLE_PUSH, enabled ? TRUE : FALSE); return this; }
/** * Sets the {@code SETTINGS_MAX_CONCURRENT_STREAMS} value. * * @throws IllegalArgumentException if verification of the setting fails. */ public Http2Settings maxConcurrentStreams(long value) { put(SETTINGS_MAX_CONCURRENT_STREAMS, Long.valueOf(value)); return this; }
/** * Sets the {@code SETTINGS_HEADER_TABLE_SIZE} value. * * @throws IllegalArgumentException if verification of the setting fails. */ public Http2Settings headerTableSize(long value) { put(SETTINGS_HEADER_TABLE_SIZE, Long.valueOf(value)); return this; }
/** * Sets the {@code SETTINGS_INITIAL_WINDOW_SIZE} value. * * @throws IllegalArgumentException if verification of the setting fails. */ public Http2Settings initialWindowSize(int value) { put(SETTINGS_INITIAL_WINDOW_SIZE, Long.valueOf(value)); return this; }
/** * Sets the {@code SETTINGS_MAX_FRAME_SIZE} value. * * @throws IllegalArgumentException if verification of the setting fails. */ public Http2Settings maxFrameSize(int value) { put(SETTINGS_MAX_FRAME_SIZE, Long.valueOf(value)); return this; }
/** * Sets the {@code SETTINGS_MAX_HEADER_LIST_SIZE} value. * * @throws IllegalArgumentException if verification of the setting fails. */ public Http2Settings maxHeaderListSize(long value) { put(SETTINGS_MAX_HEADER_LIST_SIZE, Long.valueOf(value)); return this; }
static Http2Settings decodeSettings(String base64Settings) { try { Http2Settings settings = new Http2Settings(); Buffer buffer = Buffer.buffer(Base64.getUrlDecoder().decode(base64Settings)); int pos = 0; int len = buffer.length(); while (pos < len) { int i = buffer.getUnsignedShort(pos); pos += 2; long j = buffer.getUnsignedInt(pos); pos += 4; settings.put((char)i, (Long)j); } return settings; } catch (Exception ignore) { } return null; }
private void readSettingsFrame(ChannelHandlerContext ctx, ByteBuf payload, Http2FrameListener listener) throws Http2Exception { if (flags.ack()) { listener.onSettingsAckRead(ctx); } else { int numSettings = payloadLength / SETTING_ENTRY_LENGTH; Http2Settings settings = new Http2Settings(); for (int index = 0; index < numSettings; ++index) { char id = (char) payload.readUnsignedShort(); long value = payload.readUnsignedInt(); try { settings.put(id, Long.valueOf(value)); } catch (IllegalArgumentException e) { switch(id) { case SETTINGS_MAX_FRAME_SIZE: throw connectionError(PROTOCOL_ERROR, e, e.getMessage()); case SETTINGS_INITIAL_WINDOW_SIZE: throw connectionError(FLOW_CONTROL_ERROR, e, e.getMessage()); default: throw connectionError(PROTOCOL_ERROR, e, e.getMessage()); } } } listener.onSettingsRead(ctx, settings); } }
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); }); } } }
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; }
static Http2Settings decodeSettings(String base64Settings) { try { Http2Settings settings = new Http2Settings(); Buffer buffer = Buffer.buffer(Base64.getUrlDecoder().decode(base64Settings)); int pos = 0; int len = buffer.length(); while (pos < len) { int i = buffer.getUnsignedShort(pos); pos += 2; long j = buffer.getUnsignedInt(pos); pos += 4; settings.put((char)i, (Long)j); } return settings; } catch (Exception ignore) { } return null; }
/** * Sets the {@code SETTINGS_ENABLE_PUSH} value. */ public Http2Settings pushEnabled(boolean enabled) { put(SETTINGS_ENABLE_PUSH, enabled ? TRUE : FALSE); return this; }
/** * Sets the {@code SETTINGS_ENABLE_PUSH} value. */ public Http2Settings pushEnabled(boolean enabled) { put(SETTINGS_ENABLE_PUSH, enabled ? TRUE : FALSE); return this; }
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); }); } } }
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; }
/** * Sets the {@code SETTINGS_HEADER_TABLE_SIZE} value. * * @throws IllegalArgumentException if verification of the setting fails. */ public Http2Settings headerTableSize(long value) { put(SETTINGS_HEADER_TABLE_SIZE, Long.valueOf(value)); return this; }
/** * Sets the {@code SETTINGS_MAX_FRAME_SIZE} value. * * @throws IllegalArgumentException if verification of the setting fails. */ public Http2Settings maxFrameSize(int value) { put(SETTINGS_MAX_FRAME_SIZE, Long.valueOf(value)); return this; }
/** * Sets the {@code SETTINGS_MAX_HEADER_LIST_SIZE} value. * * @throws IllegalArgumentException if verification of the setting fails. */ public Http2Settings maxHeaderListSize(long value) { put(SETTINGS_MAX_HEADER_LIST_SIZE, Long.valueOf(value)); return this; }
/** * Sets the {@code SETTINGS_MAX_HEADER_LIST_SIZE} value. * * @throws IllegalArgumentException if verification of the setting fails. */ public Http2Settings maxHeaderListSize(long value) { put(SETTINGS_MAX_HEADER_LIST_SIZE, Long.valueOf(value)); return this; }
/** * Sets the {@code SETTINGS_INITIAL_WINDOW_SIZE} value. * * @throws IllegalArgumentException if verification of the setting fails. */ public Http2Settings initialWindowSize(int value) { put(SETTINGS_INITIAL_WINDOW_SIZE, Long.valueOf(value)); return this; }