Package java.net

Examples of java.net.ProxySelector.select()

@param uri The URI that a connection is required to @return a List of Proxies. Each element in thethe List is of type {@link java.net.Proxy Proxy}; when no proxy is available, the list will contain one element of type {@link java.net.Proxy Proxy}that represents a direct connection. @throws IllegalArgumentException if either argument is null

            targetURI = new URI(target.toURI());
        } catch (URISyntaxException usx) {
            throw new HttpException
                ("Cannot convert host to URI: " + target, usx);
        }
        List<Proxy> proxies = psel.select(targetURI);

        Proxy p = chooseProxy(proxies, target, request, context);

        HttpHost result = null;
        if (p.type() == Proxy.Type.HTTP) {
View Full Code Here


        if(!sel.getClass().getName().equals("sun.net.spi.DefaultProxySelector"))
            // user-defined proxy. may return a different proxy for each invocation
            return null;

        Iterator<Proxy> it = sel.select(uri).iterator();
        if(it.hasNext())
            return it.next();

        return Proxy.NO_PROXY;
    }
View Full Code Here

        if(!sel.getClass().getName().equals("sun.net.spi.DefaultProxySelector"))
            // user-defined proxy. may return a different proxy for each invocation
            return null;

        Iterator<Proxy> it = sel.select(uri).iterator();
        if(it.hasNext())
            return it.next();

        return Proxy.NO_PROXY;
    }
View Full Code Here

                                return ProxySelector.getDefault();
                            }
                            });
            if (sel != null) {
                URI uri = sun.net.www.ParseUtil.toURI(url);
                Iterator<Proxy> it = sel.select(uri).iterator();
                while (it.hasNext()) {
                    p = it.next();
                    if (p == null || p == Proxy.NO_PROXY ||
                        p.type() == Proxy.Type.SOCKS)
                        break;
View Full Code Here

                                 }
                             });
                Proxy p = null;
                if (sel != null) {
                    URI uri = sun.net.www.ParseUtil.toURI(url);
                    Iterator<Proxy> it = sel.select(uri).iterator();
                    while (it.hasNext()) {
                        p = it.next();
                        try {
                            if (!failedOnce) {
                                http = getNewHttpClient(url, p, connectTimeout);
View Full Code Here

    public static void main(String[] args) throws Exception {
        System.setProperty("http.proxyHost", "myproxy");
        System.setProperty("http.proxyPort", "8080");
        System.setProperty("http.nonProxyHosts", "host1.*");
        ProxySelector sel = ProxySelector.getDefault();
        java.util.List<Proxy> l = sel.select(new URI("http://HOST1.sun.com/"));
        if (l.get(0) != Proxy.NO_PROXY) {
            throw new RuntimeException("ProxySelector returned the wrong proxy");
        }
    }
}
View Full Code Here

        // use system default selector to get proxy list
        ProxySelector selector = ProxySelector.getDefault();
        if (null == selector) {
            return null;
        }
        return selector.select(uri);
    }

    private static final class Action implements PrivilegedAction<Boolean> {
        private final String propertyName;
View Full Code Here

            socket = getHTTPConnection(proxy);
        } else {
            // Use system-wide ProxySelect to select proxy list,
            // then try to connect via elements in the proxy list.
            ProxySelector selector = ProxySelector.getDefault();
            List<Proxy> proxyList = selector.select(uri);
            if (proxyList != null) {
                for (Proxy selectedProxy : proxyList) {
                    if (selectedProxy.type() == Proxy.Type.DIRECT) {
                        // the same as NO_PROXY
                        continue;
View Full Code Here

            targetURI = new URI(target.toURI());
        } catch (final URISyntaxException usx) {
            throw new HttpException
                ("Cannot convert host to URI: " + target, usx);
        }
        final List<Proxy> proxies = psel.select(targetURI);

        final Proxy p = chooseProxy(proxies, target, request, context);

        HttpHost result = null;
        if (p.type() == Proxy.Type.HTTP) {
View Full Code Here

            targetURI = new URI(target.toURI());
        } catch (final URISyntaxException usx) {
            throw new HttpException
                ("Cannot convert host to URI: " + target, usx);
        }
        final List<Proxy> proxies = psel.select(targetURI);

        final Proxy p = chooseProxy(proxies, target, request, context);

        HttpHost result = null;
        if (p.type() == Proxy.Type.HTTP) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.