harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paulex Yang <paulex.y...@gmail.com>
Subject bug-to-bug compatiblity case: Proxy handling
Date Thu, 30 Mar 2006 05:59:14 GMT
Hi,
About the Internet proxy properties, the Java 5 document says '*' can be 
used as wild card character for matching, as below

"http.nonProxyHosts indicates the hosts which should be connected too 
directly and not through the proxy server. The value can be a list of 
hosts, each seperated by a |, and in addition a wild card character (*) 
can be used for matching. For example: 
-Dhttp.nonProxyHosts="*.foo.com|localhost". "

But RI's behavior looks strange. The wildcard character works only if 
it's the first or last character in "host" String. Test case below shows 
the details. Shall we make Harmony be compatible with RI?

public void testNonProxyHosts() throws URISyntaxException {
        ProxySelector selector = ProxySelector.getDefault();
        List proxyList;
        Proxy proxy;

        // set http proxy
        System.setProperty("http.proxyHost", "192.168.0.1");

        // RI works as expected if '*' is the last character
        System.setProperty("http.nonProxyHosts", "10.10.*");
        proxyList = selector.select(new URI("http://10.10.1.2"));
        proxy = (Proxy) proxyList.get(0);
        assertEquals(Proxy.NO_PROXY, proxy);

        // If '*' is neither the first character nor the last character, '*'
        // RI consider '*' as a common character instead of wild card
        System.setProperty("http.nonProxyHosts", "10.10.*.2");
        proxyList = selector.select(new URI("http://10.10.*.2"));
        proxy = (Proxy) proxyList.get(0);
        assertEquals(Proxy.NO_PROXY, proxy);

        // the test below confirms that the '*' is not considered as 
wild card
        System.setProperty("http.nonProxyHosts", "10.10.*.2");
        proxyList = selector.select(new URI("http://10.10.1.2"));
        proxy = (Proxy) proxyList.get(0);
        assertEquals(Proxy.Type.HTTP, proxy.type());
        assertEquals("192.168.0.1:80", proxy.address().toString());
    }

-- 
Paulex Yang
China Software Development Lab
IBM



Mime
View raw message