@Override protected HttpToHttp2ConnectionHandler build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings) { return new HttpToHttp2ConnectionHandler(decoder, encoder, initialSettings, isValidateHeaders()); } }
new SimpleChannelPromiseAggregator(promise, ctx.channel(), ctx.executor()); try { Http2ConnectionEncoder encoder = encoder(); boolean endStream = false; if (msg instanceof HttpMessage) { currentStreamId = getStreamId(httpMsg.headers()); writeHeaders(ctx, encoder, currentStreamId, httpMsg.headers(), http2Headers, endStream, promiseAggregator); writeHeaders(ctx, encoder, currentStreamId, trailers, http2Trailers, true, promiseAggregator); onError(ctx, true, t); promiseAggregator.setFailure(t); } finally {
/** * Get the next stream id either from the {@link HttpHeaders} object or HTTP/2 codec * * @param httpHeaders The HTTP/1.x headers object to look for the stream id * @return The stream id to use with this {@link HttpHeaders} object * @throws Exception If the {@code httpHeaders} object specifies an invalid stream id */ private int getStreamId(HttpHeaders httpHeaders) throws Exception { return httpHeaders.getInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), connection().local().incrementAndGetNextStreamId()); }
public NettyPush(final ChannelHandlerContext ctx, final int streamId, final String authority, final String scheme) { this.ctx = ctx; HttpToHttp2ConnectionHandler handler = ctx.pipeline().get(HttpToHttp2ConnectionHandler.class); this.encoder = handler.encoder(); this.streamId = streamId; this.authority = authority; this.scheme = scheme; }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof HttpServerUpgradeHandler.UpgradeEvent) { HttpServerUpgradeHandler.UpgradeEvent upgradeEvent = (HttpServerUpgradeHandler.UpgradeEvent) evt; // Map initial request headers to HTTP2 FullHttpRequest request = upgradeEvent.upgradeRequest(); Http2Headers headers = new DefaultHttp2Headers() .method(HttpMethod.GET.asciiName()) .path(request.uri()) .scheme(HttpScheme.HTTP.name()); CharSequence host = request.headers().get(HttpHeaderNames.HOST); if (host != null) { headers.authority(host); } // Process mapped headers onHeadersRead(ctx, 1, headers, 0, true); } super.userEventTriggered(ctx, evt); }
public NettyPush(final ChannelHandlerContext ctx, final int streamId, final String authority, final String scheme) { this.ctx = ctx; HttpToHttp2ConnectionHandler handler = ctx.pipeline().get(HttpToHttp2ConnectionHandler.class); this.encoder = handler.encoder(); this.streamId = streamId; this.authority = authority; this.scheme = scheme; }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof HttpServerUpgradeHandler.UpgradeEvent) { HttpServerUpgradeHandler.UpgradeEvent upgradeEvent = (HttpServerUpgradeHandler.UpgradeEvent) evt; // Map initial request headers to HTTP2 FullHttpRequest request = upgradeEvent.upgradeRequest(); Http2Headers headers = new DefaultHttp2Headers() .method(HttpMethod.GET.asciiName()) .path(request.uri()) .scheme(HttpScheme.HTTP.name()); CharSequence host = request.headers().get(HttpHeaderNames.HOST); if (host != null) { headers.authority(host); } // Process mapped headers onHeadersRead(ctx, 1, headers, 0, true); } super.userEventTriggered(ctx, evt); }
new SimpleChannelPromiseAggregator(promise, ctx.channel(), ctx.executor()); try { Http2ConnectionEncoder encoder = encoder(); boolean endStream = false; if (msg instanceof HttpMessage) { currentStreamId = getStreamId(httpMsg.headers()); writeHeaders(ctx, encoder, currentStreamId, httpMsg.headers(), http2Headers, endStream, promiseAggregator); writeHeaders(ctx, encoder, currentStreamId, trailers, http2Trailers, true, promiseAggregator); onError(ctx, true, t); promiseAggregator.setFailure(t); } finally {
@Override protected HttpToHttp2ConnectionHandler build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings) { return new HttpToHttp2ConnectionHandler(decoder, encoder, initialSettings, isValidateHeaders()); } }
/** * Get the next stream id either from the {@link HttpHeaders} object or HTTP/2 codec * * @param httpHeaders The HTTP/1.x headers object to look for the stream id * @return The stream id to use with this {@link HttpHeaders} object * @throws Exception If the {@code httpHeaders} object specifies an invalid stream id */ private int getStreamId(HttpHeaders httpHeaders) throws Exception { return httpHeaders.getInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), connection().local().incrementAndGetNextStreamId()); }
new SimpleChannelPromiseAggregator(promise, ctx.channel(), ctx.executor()); try { Http2ConnectionEncoder encoder = encoder(); boolean endStream = false; if (msg instanceof HttpMessage) { currentStreamId = getStreamId(httpMsg.headers()); writeHeaders(ctx, encoder, currentStreamId, httpMsg.headers(), http2Headers, endStream, promiseAggregator); writeHeaders(ctx, encoder, currentStreamId, trailers, http2Trailers, true, promiseAggregator); onError(ctx, true, t); promiseAggregator.setFailure(t); } finally {
@Override protected HttpToHttp2ConnectionHandler build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings) { return new HttpToHttp2ConnectionHandler(decoder, encoder, initialSettings, isValidateHeaders()); } }
/** * Get the next stream id either from the {@link HttpHeaders} object or HTTP/2 codec * * @param httpHeaders The HTTP/1.x headers object to look for the stream id * @return The stream id to use with this {@link HttpHeaders} object * @throws Exception If the {@code httpHeaders} object specifies an invalid stream id */ private int getStreamId(HttpHeaders httpHeaders) throws Exception { return httpHeaders.getInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(), connection().local().incrementAndGetNextStreamId()); }
@Override public void initChannel(SocketChannel ch) throws Exception { final Http2Connection connection = new DefaultHttp2Connection(false); final Http2FrameWriter frameWriter = frameWriter(); connectionHandler = new HttpToHttp2ConnectionHandler(connection, frameReader(), frameWriter, new DelegatingDecompressorFrameListener(connection, new InboundHttp2ToHttpAdapter.Builder(connection) .maxContentLength(maxContentLength) .propagateSettings(true) .build())); responseHandler = new HttpResponseHandler(); settingsHandler = new Http2SettingsHandler(ch.newPromise()); if (sslCtx != null) { configureSsl(ch); } else { configureClearText(ch); } }