equal
deleted
inserted
replaced
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
|
24 import java.net.InetSocketAddress; |
24 import java.net.ServerSocket; |
25 import java.net.ServerSocket; |
25 import java.net.URI; |
26 import java.net.URI; |
26 import java.net.http.HttpClient; |
27 import java.net.http.HttpClient; |
27 import java.net.http.HttpRequest; |
28 import java.net.http.HttpRequest; |
28 import java.net.http.HttpResponse.BodyHandlers; |
29 import java.net.http.HttpResponse.BodyHandlers; |
38 |
39 |
39 static volatile Throwable throwable; |
40 static volatile Throwable throwable; |
40 |
41 |
41 public static void main(String[] args) throws Exception { |
42 public static void main(String[] args) throws Exception { |
42 HttpClient client = HttpClient.newHttpClient(); |
43 HttpClient client = HttpClient.newHttpClient(); |
43 try (ServerSocket ss = new ServerSocket(0, 20)) { |
44 try (ServerSocket ss = new ServerSocket()) { |
|
45 ss.setReuseAddress(false); |
|
46 ss.bind(new InetSocketAddress(0)); |
44 int port = ss.getLocalPort(); |
47 int port = ss.getLocalPort(); |
45 URI uri = new URI("http://127.0.0.1:" + port + "/"); |
48 URI uri = new URI("http://127.0.0.1:" + port + "/"); |
46 |
49 |
47 HttpRequest request = HttpRequest.newBuilder(uri).build(); |
50 HttpRequest request = HttpRequest.newBuilder(uri).build(); |
48 |
51 |