use of io.vertx.core.http.impl.HttpClientConnection in project vert.x by eclipse.
the class Http2ClientTest method testClearText.
private void testClearText(boolean upgrade) throws Exception {
Assume.assumeTrue(testAddress.isInetSocket());
ServerBootstrap bootstrap = createH2CServer((dec, enc) -> new Http2EventAdapter() {
@Override
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream) throws Http2Exception {
enc.writeHeaders(ctx, streamId, new DefaultHttp2Headers().status("200"), 0, true, ctx.newPromise());
ctx.flush();
}
}, upgrade);
ChannelFuture s = bootstrap.bind(DEFAULT_HTTPS_HOST, DEFAULT_HTTPS_PORT).sync();
try {
client.close();
client = vertx.createHttpClient(clientOptions.setUseAlpn(false).setSsl(false).setHttp2ClearTextUpgrade(upgrade));
client.request(requestOptions).onComplete(onSuccess(req1 -> {
req1.send(onSuccess(resp1 -> {
HttpConnection conn = resp1.request().connection();
assertEquals(HttpVersion.HTTP_2, resp1.version());
client.request(requestOptions).onComplete(onSuccess(req2 -> {
req2.send(onSuccess(resp2 -> {
assertSame(((HttpClientConnection) conn).channel(), ((HttpClientConnection) resp2.request().connection()).channel());
testComplete();
}));
}));
}));
}));
await();
} finally {
s.channel().close().sync();
}
}
Aggregations