use of io.vertx.core.http.impl.HttpRequestHead in project vert.x by eclipse.
the class HttpClientConnectionTest method testConnectionClose.
@Test
public void testConnectionClose() throws Exception {
waitFor(2);
server.requestHandler(req -> {
req.response().close();
});
startServer(testAddress);
client.connect(testAddress, peerAddress).onComplete(onSuccess(conn -> {
AtomicInteger evictions = new AtomicInteger();
conn.evictionHandler(v -> {
assertEquals(1, evictions.incrementAndGet());
complete();
});
conn.createStream((ContextInternal) vertx.getOrCreateContext(), onSuccess(stream -> {
stream.writeHead(new HttpRequestHead(HttpMethod.GET, "/", MultiMap.caseInsensitiveMultiMap(), "localhost:8080", "", null), false, Unpooled.EMPTY_BUFFER, true, new StreamPriority(), false, onSuccess(v -> {
}));
stream.headHandler(resp -> {
fail();
});
stream.endHandler(headers -> {
fail();
});
stream.closeHandler(v -> {
assertEquals(1, evictions.get());
complete();
});
}));
}));
await();
}
use of io.vertx.core.http.impl.HttpRequestHead in project vert.x by eclipse.
the class HttpClientConnectionTest method testGet.
@Test
public void testGet() throws Exception {
waitFor(3);
server.requestHandler(req -> {
req.response().end();
});
startServer(testAddress);
client.connect(testAddress, peerAddress).onComplete(onSuccess(conn -> {
conn.createStream((ContextInternal) vertx.getOrCreateContext(), onSuccess(stream -> {
stream.writeHead(new HttpRequestHead(HttpMethod.GET, "/", MultiMap.caseInsensitiveMultiMap(), "localhost:8080", "", null), false, Unpooled.EMPTY_BUFFER, true, new StreamPriority(), false, onSuccess(v -> {
}));
stream.headHandler(resp -> {
assertEquals(200, resp.statusCode);
complete();
});
stream.endHandler(headers -> {
assertEquals(0, headers.size());
complete();
});
stream.closeHandler(v -> {
complete();
});
}));
}));
await();
}
use of io.vertx.core.http.impl.HttpRequestHead in project vert.x by eclipse.
the class Http1xClientConnectionTest method testServerConnectionClose.
@Test
public void testServerConnectionClose() throws Exception {
waitFor(1);
server.requestHandler(req -> {
req.response().putHeader("Connection", "close").end();
});
startServer(testAddress);
client.connect(testAddress).onComplete(onSuccess(conn -> {
AtomicInteger evictions = new AtomicInteger();
conn.evictionHandler(v -> {
assertEquals(1, evictions.incrementAndGet());
});
conn.createStream((ContextInternal) vertx.getOrCreateContext(), onSuccess(stream -> {
stream.closeHandler(v -> {
assertEquals(1, evictions.get());
complete();
});
stream.writeHead(new HttpRequestHead(HttpMethod.GET, "/", MultiMap.caseInsensitiveMultiMap(), "localhost:8080", "", null), false, Unpooled.EMPTY_BUFFER, true, new StreamPriority(), false, null);
}));
}));
await();
}
use of io.vertx.core.http.impl.HttpRequestHead in project vert.x by eclipse.
the class Http1xClientConnectionTest method testResetStreamRequestSent.
@Test
public void testResetStreamRequestSent() throws Exception {
waitFor(1);
Promise<Void> continuation = Promise.promise();
server.requestHandler(req -> {
continuation.complete();
});
startServer(testAddress);
client.connect(testAddress).onComplete(onSuccess(conn -> {
AtomicInteger evictions = new AtomicInteger();
conn.evictionHandler(v -> {
evictions.incrementAndGet();
});
conn.createStream((ContextInternal) vertx.getOrCreateContext(), onSuccess(stream -> {
Exception cause = new Exception();
stream.closeHandler(v -> {
assertEquals(1, evictions.get());
complete();
});
continuation.future().onSuccess(v -> {
stream.reset(cause);
});
stream.writeHead(new HttpRequestHead(HttpMethod.GET, "/", MultiMap.caseInsensitiveMultiMap(), "localhost:8080", "", null), false, Unpooled.EMPTY_BUFFER, false, new StreamPriority(), false, null);
}));
}));
await();
}
Aggregations