Package java.net

Examples of java.net.Proxy.type()


    public HttpConnection(HttpConfiguration config, int connectTimeout) throws IOException {
        this.config = config;
        String hostName = config.getHostName();
        int hostPort = config.getHostPort();
        Proxy proxy = config.getProxy();
        if(proxy == null || proxy.type() == Proxy.Type.HTTP) {
            socket = new Socket();
        } else {
            socket = new Socket(proxy);
        }
        socket.connect(new InetSocketAddress(hostName, hostPort), connectTimeout);
View Full Code Here


        List<Proxy> proxies = psel.select(targetURI);

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

        HttpHost result = null;
        if (p.type() == Proxy.Type.HTTP) {
            // convert the socket address to an HttpHost
            if (!(p.address() instanceof InetSocketAddress)) {
                throw new HttpException
                    ("Unable to handle non-Inet proxy address: "+p.address());
            }
View Full Code Here

        // check the list for one we can use
        for (int i=0; (result == null) && (i < proxies.size()); i++) {

            Proxy p = proxies.get(i);
            switch (p.type()) {

            case DIRECT:
            case HTTP:
                result = p;
                break;
View Full Code Here

   * @tests java.net.Proxy#Proxy(java.net.Proxy.Type, SocketAddress)
   */
  public void test_ConstructorLjava_net_ProxyLjava_net_SocketAddress_Normal() {
    // test HTTP type proxy
    Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
    assertEquals(Proxy.Type.HTTP, proxy.type());
    assertEquals(address, proxy.address());

    // test SOCKS type proxy
    proxy = new Proxy(Proxy.Type.SOCKS, address);
    assertEquals(Proxy.Type.SOCKS, proxy.type());
View Full Code Here

    assertEquals(Proxy.Type.HTTP, proxy.type());
    assertEquals(address, proxy.address());

    // test SOCKS type proxy
    proxy = new Proxy(Proxy.Type.SOCKS, address);
    assertEquals(Proxy.Type.SOCKS, proxy.type());
    assertEquals(address, proxy.address());

    // test DIRECT type proxy
    proxy = Proxy.NO_PROXY;
    assertEquals(Proxy.Type.DIRECT, proxy.type());
View Full Code Here

    assertEquals(Proxy.Type.SOCKS, proxy.type());
    assertEquals(address, proxy.address());

    // test DIRECT type proxy
    proxy = Proxy.NO_PROXY;
    assertEquals(Proxy.Type.DIRECT, proxy.type());
    assertNull(proxy.address());
  }

  /**
   * @tests java.net.Proxy#Proxy(java.net.Proxy.Type, SocketAddress)
View Full Code Here

   * @tests java.net.Proxy#toString()
   */
  public void test_toString() {
    Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
    // include type String
    assertTrue(proxy.toString().indexOf(proxy.type().toString()) != -1);
    // include address String
    assertTrue(proxy.toString().indexOf(proxy.address().toString()) != -1);

    proxy = new Proxy(Proxy.Type.SOCKS, address);
    // include type String
View Full Code Here

    // include address String
    assertTrue(proxy.toString().indexOf(proxy.address().toString()) != -1);

    proxy = new Proxy(Proxy.Type.SOCKS, address);
    // include type String
    assertTrue(proxy.toString().indexOf(proxy.type().toString()) != -1);
    // include address String
    assertTrue(proxy.toString().indexOf(proxy.address().toString()) != -1);

    proxy = Proxy.NO_PROXY;
    // include type String
View Full Code Here

    // include address String
    assertTrue(proxy.toString().indexOf(proxy.address().toString()) != -1);

    proxy = Proxy.NO_PROXY;
    // include type String
    assertTrue(proxy.toString().indexOf(proxy.type().toString()) != -1);

    proxy = new Proxy(null, address);
    // ensure no NPE is thrown
    proxy.toString();
View Full Code Here

        List<Proxy> proxies = psel.select(targetURI);

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

        HttpHost result = null;
        if (p.type() == Proxy.Type.HTTP) {
            // convert the socket address to an HttpHost
            if (!(p.address() instanceof InetSocketAddress)) {
                throw new HttpException
                    ("Unable to handle non-Inet proxy address: "+p.address());
            }
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.