Package org.apache.http.conn

Examples of org.apache.http.conn.ClientConnectionManager


        ManagedClientConnectionImpl managedConn = (ManagedClientConnectionImpl) conn;
        synchronized (managedConn) {
            if (managedConn.getPoolEntry() == null) {
                return; // already released
            }
            ClientConnectionManager manager = managedConn.getManager();
            if (manager != null && manager != this) {
                throw new IllegalStateException("Connection not obtained from this manager");
            }
            synchronized (this) {
                try {
View Full Code Here


        ConnAdapter sca = (ConnAdapter) conn;
        synchronized (sca) {
            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.");
            }
            try {
View Full Code Here

    @Test
    public void testUsesBackendsConnectionManager() {
        expect(mockBackend.getConnectionManager()).andReturn(
                mockConnectionManager);
        replayMocks();
        ClientConnectionManager result = impl.getConnectionManager();
        verifyMocks();
        Assert.assertSame(result, mockConnectionManager);
    }
View Full Code Here

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

        ClientConnectionManager connManager = null;       
       
        HttpParams params = getParams();
        String className = (String) params.getParameter(
                HttpClientParams.CONNECTION_MANAGER_FACTORY);
       
View Full Code Here

    } // 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

    } // 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

        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);
        ManagedClientConnection conn = clcm.getConnection(route);
        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);
        }

    } // main
View Full Code Here

                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

        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);
        ManagedClientConnection conn = clcm.getConnection(route);
        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.tunnelCreated(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);
        }

    } // main
View Full Code Here

                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

TOP

Related Classes of org.apache.http.conn.ClientConnectionManager

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.