equal
deleted
inserted
replaced
22 */ |
22 */ |
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 8144008 |
26 * @bug 8144008 |
|
27 * @library /test/lib |
27 * @summary Setting NO_PROXY on HTTP URL connections does not stop proxying |
28 * @summary Setting NO_PROXY on HTTP URL connections does not stop proxying |
28 * @run main/othervm NoProxyTest |
29 * @run main/othervm NoProxyTest |
29 */ |
30 */ |
30 |
31 |
31 import java.io.IOException; |
32 import java.io.IOException; |
|
33 import java.net.InetAddress; |
32 import java.net.MalformedURLException; |
34 import java.net.MalformedURLException; |
33 import java.net.Proxy; |
35 import java.net.Proxy; |
34 import java.net.ProxySelector; |
36 import java.net.ProxySelector; |
35 import java.net.SocketAddress; |
37 import java.net.SocketAddress; |
36 import java.net.URI; |
38 import java.net.URI; |
37 import java.net.URL; |
39 import java.net.URL; |
38 import java.net.URLConnection; |
40 import java.net.URLConnection; |
39 import java.util.List; |
41 import java.util.List; |
|
42 import jdk.test.lib.net.URIBuilder; |
40 |
43 |
41 public class NoProxyTest { |
44 public class NoProxyTest { |
42 |
45 |
43 static class NoProxyTestSelector extends ProxySelector { |
46 static class NoProxyTestSelector extends ProxySelector { |
44 @Override |
47 @Override |
50 } |
53 } |
51 |
54 |
52 public static void main(String args[]) throws MalformedURLException { |
55 public static void main(String args[]) throws MalformedURLException { |
53 ProxySelector.setDefault(new NoProxyTestSelector()); |
56 ProxySelector.setDefault(new NoProxyTestSelector()); |
54 |
57 |
55 URL url = URI.create("http://127.0.0.1/").toURL(); |
58 URL url = URIBuilder.newBuilder() |
|
59 .scheme("http") |
|
60 .loopback() |
|
61 .path("/") |
|
62 .toURLUnchecked(); |
|
63 System.out.println("URL: " + url); |
56 URLConnection connection; |
64 URLConnection connection; |
57 try { |
65 try { |
58 connection = url.openConnection(Proxy.NO_PROXY); |
66 connection = url.openConnection(Proxy.NO_PROXY); |
59 connection.connect(); |
67 connection.connect(); |
60 } catch (IOException ignore) { |
68 } catch (IOException ignore) { |