Examples of ClientConnectionManager


Examples of org.apache.http.conn.ClientConnectionManager

        // TODO put this values to a configuration way ???
        params.setParameter( ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 30 );
        params.setParameter( ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean( 30 ) );
        HttpProtocolParams.setVersion( params, HttpVersion.HTTP_1_1 );

        ClientConnectionManager cm = new ThreadSafeClientConnManager( params, schemeRegistry );

        httpClient = new DefaultHttpClient( cm, params );
    }
View Full Code Here

Examples of org.apache.http.conn.ClientConnectionManager

        SchemeRegistry supportedSchemes = new SchemeRegistry();
        supportedSchemes.register(new Scheme(HttpHost.DEFAULT_SCHEME_NAME, PlainSocketFactory.getSocketFactory(), 80));
        supportedSchemes.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

        ClientConnectionManager connectionManager =
            new ThreadSafeClientConnManager(defaultParameters, supportedSchemes);



        return new DefaultHttpClient(connectionManager, defaultParameters);
View Full Code Here

Examples of org.apache.http.conn.ClientConnectionManager

        }

        ConnAdapter sca = (ConnAdapter) conn;
        if (sca.poolEntry == null)
            return; // already released
        ClientConnectionManager manager = sca.getManager();
        if (manager != null && manager != this) {
            throw new IllegalArgumentException
                ("Connection not obtained from this manager.");
        }
View Full Code Here

Examples of org.apache.http.conn.ClientConnectionManager

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

        setup(); // some general setup

        ClientConnectionManager clcm = createManager();

        HttpRequest req = createRequest(target);
        HttpContext ctx = createContext();

        System.out.println("preparing route to " + target);
        HttpRoute route = new HttpRoute
            (target, null, supportedSchemes.getScheme(target).isLayered());

        System.out.println("requesting connection for " + route);
        ClientConnectionRequest connRequest = clcm.requestConnection(route, null);
        ManagedClientConnection conn = connRequest.getConnection(0, null);
        try {
            System.out.println("opening connection");
            conn.open(route, ctx, getParams());

            System.out.println("sending request");
            conn.sendRequestHeader(req);
            // there is no request entity
            conn.flush();

            System.out.println("receiving response header");
            HttpResponse rsp = conn.receiveResponseHeader();

            System.out.println("----------------------------------------");
            System.out.println(rsp.getStatusLine());
            Header[] headers = rsp.getAllHeaders();
            for (int i=0; i<headers.length; i++) {
                System.out.println(headers[i]);
            }
            System.out.println("----------------------------------------");

            System.out.println("closing connection");
            conn.close();

        } finally {

            if (conn.isOpen()) {
                System.out.println("shutting down connection");
                try {
                    conn.shutdown();
                } catch (Exception x) {
                    System.out.println("problem during shutdown");
                    x.printStackTrace(System.out);
                }
            }

            System.out.println("releasing connection");
            clcm.releaseConnection(conn, -1, null);
        }

    } // main
View Full Code Here

Examples of org.apache.http.conn.ClientConnectionManager

                new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
       
        // Create an HttpClient with the ThreadSafeClientConnManager.
        // This connection manager must be used if more than one thread will
        // be using the HttpClient.
        ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
        HttpClient httpClient = new DefaultHttpClient(cm, params);
       
        // create an array of URIs to perform GETs on
        String[] urisToGet = {
            "http://jakarta.apache.org/",
View Full Code Here

Examples of org.apache.http.conn.ClientConnectionManager

        final HttpHost proxy =
            new HttpHost("127.0.0.1", 8666, "http");

        setup(); // some general setup

        ClientConnectionManager clcm = createManager();

        HttpRequest req = createRequest(target);
        HttpContext ctx = createContext();

        System.out.println("preparing route to " + target + " via " + proxy);
        HttpRoute route = new HttpRoute
            (target, null, proxy,
             supportedSchemes.getScheme(target).isLayered());

        System.out.println("requesting connection for " + route);
        ClientConnectionRequest connRequest = clcm.requestConnection(route, null);
        ManagedClientConnection conn = connRequest.getConnection(0, null);
        try {
            System.out.println("opening connection");
            conn.open(route, ctx, getParams());

            HttpRequest connect = createConnect(target);
            System.out.println("opening tunnel to " + target);
            conn.sendRequestHeader(connect);
            // there is no request entity
            conn.flush();

            System.out.println("receiving confirmation for tunnel");
            HttpResponse connected = conn.receiveResponseHeader();
            System.out.println("----------------------------------------");
            printResponseHeader(connected);
            System.out.println("----------------------------------------");
            int status = connected.getStatusLine().getStatusCode();
            if ((status < 200) || (status > 299)) {
                System.out.println("unexpected status code " + status);
                System.exit(1);
            }
            System.out.println("receiving response body (ignored)");
            conn.receiveResponseEntity(connected);

            conn.tunnelTarget(false, getParams());

            System.out.println("layering secure connection");
            conn.layerProtocol(ctx, getParams());

            // finally we have the secure connection and can send the request

            System.out.println("sending request");
            conn.sendRequestHeader(req);
            // there is no request entity
            conn.flush();

            System.out.println("receiving response header");
            HttpResponse rsp = conn.receiveResponseHeader();

            System.out.println("----------------------------------------");
            printResponseHeader(rsp);
            System.out.println("----------------------------------------");

            System.out.println("closing connection");
            conn.close();

        } finally {

            if (conn.isOpen()) {
                System.out.println("shutting down connection");
                try {
                    conn.shutdown();
                } catch (Exception x) {
                    System.out.println("problem during shutdown");
                    x.printStackTrace(System.out);
                }
            }

            System.out.println("releasing connection");
            clcm.releaseConnection(conn, -1, null);
        }

    } // main
View Full Code Here

Examples of org.apache.http.conn.ClientConnectionManager

    } // main


    private final static HttpClient createHttpClient() {

        ClientConnectionManager ccm =
            new ThreadSafeClientConnManager(getParams(), supportedSchemes);
        //  new SingleClientConnManager(getParams(), supportedSchemes);

        DefaultHttpClient dhc =
            new DefaultHttpClient(ccm, getParams());
View Full Code Here

Examples of org.apache.http.conn.ClientConnectionManager

    } // main


    private final static HttpClient createHttpClient() {

        ClientConnectionManager ccm =
            new ThreadSafeClientConnManager(getParams(), supportedSchemes);
        //  new SingleClientConnManager(getParams(), supportedSchemes);

        DefaultHttpClient dhc =
            new DefaultHttpClient(ccm, getParams());
View Full Code Here

Examples of org.apache.http.conn.ClientConnectionManager

        registry.register(
                new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(
                new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

        ClientConnectionManager connManager = null;    
        HttpParams params = getParams();
       
        ClientConnectionManagerFactory factory = null;

        // Try first getting the factory directly as an object.
View Full Code Here

Examples of org.apache.http.conn.ClientConnectionManager

        registry.register(
                new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
        registry.register(
                new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));

        ClientConnectionManager connManager = null;
        HttpParams params = getParams();

        ClientConnectionManagerFactory factory = null;

        String className = (String) params.getParameter(
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.