use of org.eclipse.jetty.http2.HTTP2Connection in project vert.x by eclipse.
the class Http2ServerTest method testPriorKnowledge.
@Test
public void testPriorKnowledge() throws Exception {
server.close();
server = vertx.createHttpServer(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTP_HOST));
server.requestHandler(req -> {
req.response().end("Hello World");
});
startServer();
TestClient client = new TestClient() {
@Override
protected ChannelInitializer channelInitializer(int port, String host, Consumer<Connection> handler) {
return new ChannelInitializer() {
@Override
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
Http2Connection connection = new DefaultHttp2Connection(false);
TestClientHandlerBuilder clientHandlerBuilder = new TestClientHandlerBuilder(handler);
TestClientHandler clientHandler = clientHandlerBuilder.build(connection);
p.addLast(clientHandler);
}
};
}
};
ChannelFuture fut = client.connect(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, request -> {
request.decoder.frameListener(new Http2EventAdapter() {
@Override
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream) throws Http2Exception {
vertx.runOnContext(v -> {
testComplete();
});
}
});
int id = request.nextStreamId();
request.encoder.writeHeaders(request.context, id, GET("/"), 0, true, request.context.newPromise());
request.context.flush();
});
fut.sync();
await();
}
use of org.eclipse.jetty.http2.HTTP2Connection in project vert.x by eclipse.
the class Http2ConnectionBase method checkShutdownHandler.
// Private
private void checkShutdownHandler() {
if (!shutdown) {
Http2Connection conn = handler.connection();
if ((conn.goAwayReceived() || conn.goAwaySent()) && conn.numActiveStreams() == 0) {
shutdown = true;
Handler<Void> handler = shutdownHandler;
if (handler != null) {
context.executeFromIO(() -> {
shutdownHandler.handle(null);
});
}
}
}
}
use of org.eclipse.jetty.http2.HTTP2Connection in project rest.li by linkedin.
the class Http2ClientPipelineInitializer method initChannel.
@Override
protected void initChannel(NioSocketChannel channel) throws Exception {
Http2Connection connection = new DefaultHttp2Connection(false);
channel.attr(HTTP2_CONNECTION_ATTR_KEY).set(connection);
channel.attr(CALLBACK_ATTR_KEY).set(connection.newKey());
channel.attr(CHANNEL_POOL_HANDLE_ATTR_KEY).set(connection.newKey());
Http2InitializerHandler initializerHandler = new Http2InitializerHandler(_maxHeaderSize, _maxChunkSize, _maxResponseSize, _streamingTimeout, _scheduler, connection, _sslContext, _sslParameters);
channel.pipeline().addLast("initializerHandler", initializerHandler);
}
use of org.eclipse.jetty.http2.HTTP2Connection in project grpc-java by grpc.
the class NettyServerHandler method newHandler.
@VisibleForTesting
static NettyServerHandler newHandler(Http2FrameReader frameReader, Http2FrameWriter frameWriter, ServerTransportListener transportListener, int maxStreams, int flowControlWindow, int maxHeaderListSize, int maxMessageSize) {
Preconditions.checkArgument(maxStreams > 0, "maxStreams must be positive");
Preconditions.checkArgument(flowControlWindow > 0, "flowControlWindow must be positive");
Preconditions.checkArgument(maxHeaderListSize > 0, "maxHeaderListSize must be positive");
Preconditions.checkArgument(maxMessageSize > 0, "maxMessageSize must be positive");
Http2Connection connection = new DefaultHttp2Connection(true);
// Create the local flow controller configured to auto-refill the connection window.
connection.local().flowController(new DefaultHttp2LocalFlowController(connection, DEFAULT_WINDOW_UPDATE_RATIO, true));
Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(connection, frameWriter);
// TODO(ejona): swap back to DefaultHttp2Connection with Netty-4.1.9
Http2ConnectionDecoder decoder = new FixedHttp2ConnectionDecoder(connection, encoder, frameReader);
Http2Settings settings = new Http2Settings();
settings.initialWindowSize(flowControlWindow);
settings.maxConcurrentStreams(maxStreams);
settings.maxHeaderListSize(maxHeaderListSize);
return new NettyServerHandler(transportListener, decoder, encoder, settings, maxMessageSize);
}
use of org.eclipse.jetty.http2.HTTP2Connection in project grpc-java by grpc.
the class NettyClientHandler method newHandler.
static NettyClientHandler newHandler(ClientTransportLifecycleManager lifecycleManager, @Nullable KeepAliveManager keepAliveManager, int flowControlWindow, int maxHeaderListSize, Ticker ticker) {
Preconditions.checkArgument(maxHeaderListSize > 0, "maxHeaderListSize must be positive");
Http2HeadersDecoder headersDecoder = new GrpcHttp2ClientHeadersDecoder(maxHeaderListSize);
Http2FrameReader frameReader = new DefaultHttp2FrameReader(headersDecoder);
Http2FrameWriter frameWriter = new DefaultHttp2FrameWriter();
Http2Connection connection = new DefaultHttp2Connection(false);
return newHandler(connection, frameReader, frameWriter, lifecycleManager, keepAliveManager, flowControlWindow, maxHeaderListSize, ticker);
}
Aggregations