@Override public ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings, ChannelPromise promise) { try { checkNotNull(settings, "settings"); int payloadLength = SETTING_ENTRY_LENGTH * settings.size(); ByteBuf buf = ctx.alloc().buffer(FRAME_HEADER_LENGTH + settings.size() * SETTING_ENTRY_LENGTH); writeFrameHeaderInternal(buf, payloadLength, SETTINGS, new Http2Flags(), 0); for (Http2Settings.PrimitiveEntry<Long> entry : settings.entries()) { buf.writeChar(entry.key()); buf.writeInt(entry.value().intValue()); } return ctx.write(buf, promise); } catch (Throwable t) { return promise.setFailure(t); } }
/** * Converts the current settings for the handler to the Base64-encoded representation used in * the HTTP2-Settings upgrade header. */ private CharSequence getSettingsHeaderValue(ChannelHandlerContext ctx) { ByteBuf buf = null; ByteBuf encodedBuf = null; try { // Get the local settings for the handler. Http2Settings settings = connectionHandler.decoder().localSettings(); // Serialize the payload of the SETTINGS frame. int payloadLength = SETTING_ENTRY_LENGTH * settings.size(); buf = ctx.alloc().buffer(payloadLength); for (CharObjectMap.PrimitiveEntry<Long> entry : settings.entries()) { buf.writeChar(entry.key()); buf.writeInt(entry.value().intValue()); } // Base64 encode the payload and then convert to a string for the header. encodedBuf = Base64.encode(buf, URL_SAFE); return encodedBuf.toString(UTF_8); } finally { release(buf); release(encodedBuf); } } }
@Override public ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings, ChannelPromise promise) { try { checkNotNull(settings, "settings"); int payloadLength = SETTING_ENTRY_LENGTH * settings.size(); ByteBuf buf = ctx.alloc().buffer(FRAME_HEADER_LENGTH + settings.size() * SETTING_ENTRY_LENGTH); writeFrameHeaderInternal(buf, payloadLength, SETTINGS, new Http2Flags(), 0); for (Http2Settings.PrimitiveEntry<Long> entry : settings.entries()) { buf.writeChar(entry.key()); buf.writeInt(entry.value().intValue()); } return ctx.write(buf, promise); } catch (Throwable t) { return promise.setFailure(t); } }
@Override public ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings, ChannelPromise promise) { try { checkNotNull(settings, "settings"); int payloadLength = SETTING_ENTRY_LENGTH * settings.size(); ByteBuf buf = ctx.alloc().buffer(FRAME_HEADER_LENGTH + settings.size() * SETTING_ENTRY_LENGTH); writeFrameHeaderInternal(buf, payloadLength, SETTINGS, new Http2Flags(), 0); for (Http2Settings.PrimitiveEntry<Long> entry : settings.entries()) { buf.writeChar(entry.key()); buf.writeInt(entry.value().intValue()); } return ctx.write(buf, promise); } catch (Throwable t) { return promise.setFailure(t); } }
/** * Converts the current settings for the handler to the Base64-encoded representation used in * the HTTP2-Settings upgrade header. */ private CharSequence getSettingsHeaderValue(ChannelHandlerContext ctx) { ByteBuf buf = null; ByteBuf encodedBuf = null; try { // Get the local settings for the handler. Http2Settings settings = connectionHandler.decoder().localSettings(); // Serialize the payload of the SETTINGS frame. int payloadLength = SETTING_ENTRY_LENGTH * settings.size(); buf = ctx.alloc().buffer(payloadLength); for (CharObjectMap.PrimitiveEntry<Long> entry : settings.entries()) { buf.writeChar(entry.key()); buf.writeInt(entry.value().intValue()); } // Base64 encode the payload and then convert to a string for the header. encodedBuf = Base64.encode(buf, URL_SAFE); return encodedBuf.toString(UTF_8); } finally { release(buf); release(encodedBuf); } } }
/** * Converts the current settings for the handler to the Base64-encoded representation used in * the HTTP2-Settings upgrade header. */ private CharSequence getSettingsHeaderValue(ChannelHandlerContext ctx) { ByteBuf buf = null; ByteBuf encodedBuf = null; try { // Get the local settings for the handler. Http2Settings settings = connectionHandler.decoder().localSettings(); // Serialize the payload of the SETTINGS frame. int payloadLength = SETTING_ENTRY_LENGTH * settings.size(); buf = ctx.alloc().buffer(payloadLength); for (CharObjectMap.PrimitiveEntry<Long> entry : settings.entries()) { buf.writeChar(entry.key()); buf.writeInt(entry.value().intValue()); } // Base64 encode the payload and then convert to a string for the header. encodedBuf = Base64.encode(buf, URL_SAFE); return encodedBuf.toString(UTF_8); } finally { release(buf); release(encodedBuf); } } }