Package org.apache.http.impl.conn

Examples of org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect()


        final HttpRequest request = new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
        final HttpContext context = new BasicHttpContext();

        HttpClientConnection conn = getConnection(mgr, route);
        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);

        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);

        final HttpProcessor httpProcessor = new ImmutableHttpProcessor(
View Full Code Here


        conn.close();
        mgr.releaseConnection(conn, null, -1, null);
        conn = getConnection(mgr, route);
        Assert.assertFalse("connection should have been closed", conn.isOpen());

        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);

        // repeat the communication, no need to prepare the request again
        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        response = exec.execute(request, conn, context);
View Full Code Here

        final HttpRequest request = new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
        final HttpContext context = new BasicHttpContext();

        HttpClientConnection conn = getConnection(mgr, route);
        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);

        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);

        final HttpProcessor httpProcessor = new ImmutableHttpProcessor(
View Full Code Here

        mgr.releaseConnection(conn, null, 100, TimeUnit.MILLISECONDS);
        conn = getConnection(mgr, route);
        Assert.assertFalse("connection should have been closed", conn.isOpen());

        // repeat the communication, no need to prepare the request again
        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);

        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        response = exec.execute(request, conn, context);

        Assert.assertEquals("wrong status in second response",
View Full Code Here

        Thread.sleep(150);
        conn = getConnection(mgr, route);
        Assert.assertTrue("connection should have been closed", !conn.isOpen());

        // repeat the communication, no need to prepare the request again
        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);

        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        response = exec.execute(request, conn, context);

        Assert.assertEquals("wrong status in third response",
View Full Code Here

        final HttpHost target = getServerHttp();
        final HttpRoute route = new HttpRoute(target, null, false);
        final HttpContext context = new BasicHttpContext();

        final HttpClientConnection conn = getConnection(mgr, route);
        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);

        Assert.assertEquals(1, mgr.getTotalStats().getLeased());
        Assert.assertEquals(1, mgr.getStats(route).getLeased());

        mgr.releaseConnection(conn, null, 100, TimeUnit.MILLISECONDS);
View Full Code Here

        final HttpHost target = getServerHttp();
        final HttpRoute route = new HttpRoute(target, null, false);
        final HttpContext context = new BasicHttpContext();

        final HttpClientConnection conn = getConnection(mgr, route);
        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);

        Assert.assertEquals(1, mgr.getTotalStats().getLeased());
        Assert.assertEquals(1, mgr.getStats(route).getLeased());
        // Release, let remain idle for forever
        mgr.releaseConnection(conn, null, -1, TimeUnit.MILLISECONDS);
View Full Code Here

        final HttpRequest request =
            new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);

        HttpClientConnection conn = getConnection(mgr, route);
        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);

        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);

        final HttpProcessor httpProcessor = new ImmutableHttpProcessor(
View Full Code Here

            }
        });
        abortingThread.start();

        try {
            mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
            Assert.fail("expected SocketException");
        } catch(final SocketException expected) {}

        abortingThread.join(5000);
        if(throwRef.get() != null) {
View Full Code Here

            }
        });
        abortingThread.start();

        try {
            mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
            Assert.fail("IOException expected");
        } catch(final IOException expected) {
        }

        abortingThread.join(5000);
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.