This commit is contained in:
1 parent
b724a21a0d
commit
d73fa2c435
45 files changed
+2733
-226
No files matched your search
@@ -22,6 +22,7 @@ public final class NodeHttpTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try (HttpClient client = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build()) {
|
||||
warmUp(client);
|
||||
stalledBody(client, false);
|
||||
stalledBody(client, true);
|
||||
oversizedBody(client);
|
||||
@@ -32,6 +33,22 @@ public final class NodeHttpTest {
|
||||
System.out.println("Node HTTP tests passed: total deadlines, cancellation, bounded responses, interruption");
|
||||
}
|
||||
|
||||
private static void warmUp(HttpClient client) throws Exception {
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);
|
||||
server.createContext("/", exchange -> {
|
||||
exchange.sendResponseHeaders(204, -1);
|
||||
exchange.close();
|
||||
});
|
||||
server.start();
|
||||
try {
|
||||
URI uri = URI.create("http://127.0.0.1:" + server.getAddress().getPort());
|
||||
HttpRequest request = HttpRequest.newBuilder(uri).timeout(Duration.ofSeconds(10)).GET().build();
|
||||
require(NodeHttp.bytes(client, request, 0).statusCode() == 204, "HTTP client warm-up failed");
|
||||
} finally {
|
||||
server.stop(0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void stalledBody(HttpClient client, boolean discard) throws Exception {
|
||||
try (StalledResponse server = new StalledResponse(1)) {
|
||||
HttpRequest request = HttpRequest.newBuilder(server.uri()).timeout(Duration.ofMillis(500)).GET().build();
|
||||
|
||||
Reference in new issue
Block a user