Package org.apache.http.conn.scheme

Examples of org.apache.http.conn.scheme.SchemeSocketFactory


        HttpHost target = new HttpHost("www.apache.org", 80, "http");

        // Register the "http" protocol scheme, it is required
        // by the default operator to look up socket factories.
        SchemeRegistry supportedSchemes = new SchemeRegistry();
        SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
        supportedSchemes.register(new Scheme("http", 80, sf));

        // Prepare parameters.
        // Since this example doesn't use the full core framework,
        // only few parameters are actually required.
View Full Code Here


        HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
        HttpProtocolParams.setUseExpectContinue(params, false);
        HttpConnectionParams.setStaleCheckingEnabled(params, false);

        SchemeRegistry supportedSchemes = new SchemeRegistry();
        SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
        supportedSchemes.register(new Scheme("http", 80, sf));

        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
        mgr.setMaxTotal(5);
        mgr.setDefaultMaxPerRoute(5);
View Full Code Here

        HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
        HttpProtocolParams.setUseExpectContinue(params, false);
        HttpConnectionParams.setStaleCheckingEnabled(params, false);

        SchemeRegistry supportedSchemes = new SchemeRegistry();
        SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
        supportedSchemes.register(new Scheme("http", 80, sf));

        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
        mgr.setMaxTotal(5);
        mgr.setDefaultMaxPerRoute(5);
View Full Code Here

        HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
        HttpProtocolParams.setUseExpectContinue(params, false);
        HttpConnectionParams.setStaleCheckingEnabled(params, false);

        SchemeRegistry supportedSchemes = new SchemeRegistry();
        SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
        supportedSchemes.register(new Scheme("http", 80, sf));

        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
        mgr.setMaxTotal(5);
        mgr.setDefaultMaxPerRoute(5);
View Full Code Here

        HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
        HttpProtocolParams.setUseExpectContinue(params, false);
        HttpConnectionParams.setStaleCheckingEnabled(params, false);

        SchemeRegistry supportedSchemes = new SchemeRegistry();
        SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
        supportedSchemes.register(new Scheme("http", 80, sf));

        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
        mgr.setMaxTotal(1);
        mgr.setDefaultMaxPerRoute(1);
View Full Code Here

                (defaultParams, false);
        }

        if (supportedSchemes == null) {
            supportedSchemes = new SchemeRegistry();
            SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
            supportedSchemes.register(new Scheme("http", 80, sf));
        }

        if (httpProcessor == null) {
            httpProcessor = new BasicHttpProcessor();
View Full Code Here

    } // class XTSCCM

    @Test
    public void testSpuriousWakeup() throws Exception {
        SchemeRegistry schreg = new SchemeRegistry();
        SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
        schreg.register(new Scheme("http", 80, sf));

        XTSCCM mgr = new XTSCCM(schreg);
        try {
            mgr.setMaxTotal(1);
View Full Code Here

        if (conn.isOpen()) {
            throw new IllegalStateException("Connection must not be open");
        }

        Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
        SchemeSocketFactory sf = schm.getSchemeSocketFactory();

        InetAddress[] addresses = resolveHostname(target.getHostName());
        int port = schm.resolvePort(target.getPort());
        for (int i = 0; i < addresses.length; i++) {
            InetAddress address = addresses[i];
            boolean last = i == addresses.length - 1;

            Socket sock = sf.createSocket(params);
            conn.opening(sock, target);

            InetSocketAddress remoteAddress = new InetSocketAddress(address, port);
            InetSocketAddress localAddress = null;
            if (local != null) {
                localAddress = new InetSocketAddress(local, 0);
            }
            if (this.log.isDebugEnabled()) {
                this.log.debug("Connecting to " + remoteAddress);
            }
            try {
                Socket connsock = sf.connectSocket(sock, remoteAddress, localAddress, params);
                if (sock != connsock) {
                    sock = connsock;
                    conn.opening(sock, target);
                }
                prepareSocket(sock, context, params);
                conn.openCompleted(sf.isSecure(sock), params);
                return;
            } catch (ConnectException ex) {
                if (last) {
                    throw new HttpHostConnectException(target, ex);
                }
View Full Code Here

        if (conn.isOpen()) {
            throw new IllegalStateException("Connection must not be open");
        }

        Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
        SchemeSocketFactory sf = schm.getSchemeSocketFactory();

        InetAddress[] addresses = resolveHostname(target.getHostName());
        int port = schm.resolvePort(target.getPort());
        for (int i = 0; i < addresses.length; i++) {
            InetAddress address = addresses[i];
            boolean last = i == addresses.length - 1;

            Socket sock = sf.createSocket(params);
            conn.opening(sock, target);

            InetSocketAddress remoteAddress = new HttpInetSocketAddress(target, address, port);
            InetSocketAddress localAddress = null;
            if (local != null) {
                localAddress = new InetSocketAddress(local, 0);
            }
            if (this.log.isDebugEnabled()) {
                this.log.debug("Connecting to " + remoteAddress);
            }
            try {
                Socket connsock = sf.connectSocket(sock, remoteAddress, localAddress, params);
                if (sock != connsock) {
                    sock = connsock;
                    conn.opening(sock, target);
                }
                prepareSocket(sock, context, params);
                conn.openCompleted(sf.isSecure(sock), params);
                return;
            } catch (ConnectException ex) {
                if (last) {
                    throw new HttpHostConnectException(target, ex);
                }
View Full Code Here

    if(!isSocksMode) {
      super.openConnection(conn, target, local, context, params);
      return;
    }
    final Scheme scheme = schemeRegistry.getScheme(target.getSchemeName());
    final SchemeSocketFactory sf = scheme.getSchemeSocketFactory();
   
    final int port = scheme.resolvePort(target.getPort());
    Socket sock = sf.createSocket(params);
    conn.opening(sock, target);
    InetSocketAddress remoteAddress = InetSocketAddress.createUnresolved(target.getHostName(), port);
    InetSocketAddress localAddress = null;
    if(local != null) {
      localAddress = new InetSocketAddress(local, 0);
    }
    try {
      Socket connsock = sf.connectSocket(sock, remoteAddress, localAddress, params);
      if(sock != connsock) {
        sock = connsock;
        conn.opening(sock, target);
      }
      prepareSocket(sock, context, params);
      conn.openCompleted(sf.isSecure(sock), params);
      return;
    } catch (ConnectException ex) {
      throw new HttpHostConnectException(target, ex);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.http.conn.scheme.SchemeSocketFactory

Copyright © 2018 www.massapicom. 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.