54 import java.util.Arrays; |
54 import java.util.Arrays; |
55 import java.util.Formatter; |
55 import java.util.Formatter; |
56 import java.util.HashMap; |
56 import java.util.HashMap; |
57 import java.util.LinkedList; |
57 import java.util.LinkedList; |
58 import java.util.Random; |
58 import java.util.Random; |
59 import java.util.concurrent.ExecutorService; |
|
60 import java.util.logging.Logger; |
59 import java.util.logging.Logger; |
61 import java.util.logging.Level; |
60 import java.util.logging.Level; |
62 import java.util.concurrent.CompletableFuture; |
61 import java.util.concurrent.CompletableFuture; |
63 import javax.net.ssl.SSLContext; |
62 import javax.net.ssl.SSLContext; |
64 import jdk.testlibrary.SimpleSSLContext; |
63 import jdk.testlibrary.SimpleSSLContext; |
65 import static jdk.incubator.http.HttpRequest.BodyProcessor.fromByteArray; |
64 import static jdk.incubator.http.HttpRequest.BodyPublisher.fromByteArray; |
66 import static jdk.incubator.http.HttpResponse.BodyHandler.asByteArray; |
65 import static jdk.incubator.http.HttpResponse.BodyHandler.asByteArray; |
67 |
66 |
68 public class ManyRequests { |
67 public class ManyRequests { |
69 |
68 |
70 volatile static int counter = 0; |
69 volatile static int counter = 0; |
109 System.out.println("Server: received " + e.getRequestURI()); |
107 System.out.println("Server: received " + e.getRequestURI()); |
110 super.handle(e); |
108 super.handle(e); |
111 } |
109 } |
112 protected void close(OutputStream os) throws IOException { |
110 protected void close(OutputStream os) throws IOException { |
113 if (INSERT_DELAY) { |
111 if (INSERT_DELAY) { |
114 try { Thread.sleep(rand.nextInt(200)); } catch (InterruptedException e) {} |
112 try { Thread.sleep(rand.nextInt(200)); } |
115 } |
113 catch (InterruptedException e) {} |
116 super.close(os); |
114 } |
|
115 os.close(); |
117 } |
116 } |
118 protected void close(InputStream is) throws IOException { |
117 protected void close(InputStream is) throws IOException { |
119 if (INSERT_DELAY) { |
118 if (INSERT_DELAY) { |
120 try { Thread.sleep(rand.nextInt(200)); } catch (InterruptedException e) {} |
119 try { Thread.sleep(rand.nextInt(200)); } |
121 } |
120 catch (InterruptedException e) {} |
122 super.close(is); |
121 } |
|
122 is.close(); |
123 } |
123 } |
124 } |
124 } |
125 |
125 |
126 static void test(HttpsServer server, HttpClient client) throws Exception { |
126 static void test(HttpsServer server, HttpClient client) throws Exception { |
127 int port = server.getAddress().getPort(); |
127 int port = server.getAddress().getPort(); |