Examples of HttpGet


Examples of org.apache.http.client.methods.HttpGet

        DefaultHttpClient client = new DefaultHttpClient();
        HttpResponse response;

        if(!relative) {
            String request = "http://" + host + ":" + port + uri;
            HttpGet httpget = new HttpGet(request);
            response = client.execute(httpget);
            response.getEntity().consumeContent()
        } else {
            HttpHost target = new HttpHost(host, port);
            HttpGet httpget = new HttpGet(uri);
            response = client.execute(target, httpget);
            response.getEntity().consumeContent()
        }
       
        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());      
View Full Code Here

Examples of org.apache.http.client.methods.HttpGet

        assertEquals(0, mgr.getConnectionsInPool());
       
        DefaultHttpClient client = new DefaultHttpClient(mgr, params);

        // Get some random data
        HttpGet httpget = new HttpGet("/random/20000");
        HttpHost target = getServerHttp();
       
        HttpResponse response = client.execute(target, httpget);

        ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
View Full Code Here

Examples of org.apache.http.client.methods.HttpGet

        assertEquals(0, mgr.getConnectionsInPool());
       
        DefaultHttpClient client = new DefaultHttpClient(mgr, params);

        // Get some random data
        HttpGet httpget = new HttpGet("/random/20000");
        HttpHost target = getServerHttp();
       
        HttpResponse response = client.execute(target, httpget);

        ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
View Full Code Here

Examples of org.apache.http.client.methods.HttpGet

        assertEquals(0, mgr.getConnectionsInPool());
       
        DefaultHttpClient client = new DefaultHttpClient(mgr, params);

        // Get some random data
        HttpGet httpget = new HttpGet("/random/20000");
        HttpHost target = getServerHttp();
       
        HttpResponse response = client.execute(target, httpget);

        ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
        try {
            connreq.getConnection(250, TimeUnit.MILLISECONDS);
            fail("ConnectionPoolTimeoutException should have been thrown");
        } catch (ConnectionPoolTimeoutException expected) {
        }
       
        HttpEntity e = response.getEntity();
        assertNotNull(e);
        httpget.abort();
       
        // Expect zero connections in the pool
        assertEquals(0, mgr.getConnectionsInPool());

        // Make sure one connection is available
View Full Code Here

Examples of org.apache.http.client.methods.HttpGet

        assertEquals(0, mgr.getConnectionsInPool());
       
        DefaultHttpClient client = new DefaultHttpClient(mgr, params);

        // Get some random data
        HttpGet httpget = new HttpGet("/dropdead");
        HttpHost target = getServerHttp();
       
        HttpResponse response = client.execute(target, httpget);

        ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
View Full Code Here

Examples of org.apache.http.client.methods.HttpGet

                params, supportedSchemes);

        DefaultHttpClient client = new DefaultHttpClient(mgr, params);
        HttpHost target = new HttpHost(saddress.getHostName(), saddress.getPort(), "http");
       
        HttpResponse response = client.execute(target, new HttpGet("/random/2000"));
        if(response.getEntity() != null)
            response.getEntity().consumeContent();
       
        assertEquals(1, mgr.getConnectionsInPool());
        assertEquals(1, localServer.getAcceptedConnectionCount());
       
        response = client.execute(target, new HttpGet("/random/2000"));
        if(response.getEntity() != null)
            response.getEntity().consumeContent();
       
        assertEquals(1, mgr.getConnectionsInPool());
        assertEquals(1, localServer.getAcceptedConnectionCount());
       
        // Now sleep for 1.1 seconds and let the timeout do its work
        Thread.sleep(1100);
        response = client.execute(target, new HttpGet("/random/2000"));
        if(response.getEntity() != null)
            response.getEntity().consumeContent();
       
        assertEquals(1, mgr.getConnectionsInPool());
        assertEquals(2, localServer.getAcceptedConnectionCount());
       
        // Do another request just under the 1 second limit & make
        // sure we reuse that connection.
        Thread.sleep(500);
        response = client.execute(target, new HttpGet("/random/2000"));
        if(response.getEntity() != null)
            response.getEntity().consumeContent();
       
        assertEquals(1, mgr.getConnectionsInPool());
        assertEquals(2, localServer.getAcceptedConnectionCount());
View Full Code Here

Examples of org.apache.http.client.methods.HttpGet

       
        DefaultHttpClient client = new DefaultHttpClient();
        HttpContext context = new BasicHttpContext();

        String s = "http://localhost:" + port + "/path";
        HttpGet httpget = new HttpGet(s);

        HttpResponse response = client.execute(getServerHttp(), httpget, context);
        HttpEntity e = response.getEntity();
        if (e != null) {
            e.consumeContent();
View Full Code Here

Examples of org.apache.http.client.methods.HttpGet

       
        DefaultHttpClient client = new DefaultHttpClient();
        HttpContext context = new BasicHttpContext();

        String s = "http://localhost:" + port;
        HttpGet httpget = new HttpGet(s);

        HttpResponse response = client.execute(getServerHttp(), httpget, context);
        HttpEntity e = response.getEntity();
        if (e != null) {
            e.consumeContent();
View Full Code Here

Examples of org.apache.http.client.methods.HttpGet

                new BasicRedirectService(host, port, HttpStatus.SC_MULTIPLE_CHOICES));
       
        DefaultHttpClient client = new DefaultHttpClient();
        HttpContext context = new BasicHttpContext();

        HttpGet httpget = new HttpGet("/oldlocation/");

        HttpResponse response = client.execute(getServerHttp(), httpget, context);
        HttpEntity e = response.getEntity();
        if (e != null) {
            e.consumeContent();
View Full Code Here

Examples of org.apache.http.client.methods.HttpGet

                new BasicRedirectService(host, port, HttpStatus.SC_MOVED_PERMANENTLY));
       
        DefaultHttpClient client = new DefaultHttpClient();
        HttpContext context = new BasicHttpContext();

        HttpGet httpget = new HttpGet("/oldlocation/");

        HttpResponse response = client.execute(getServerHttp(), httpget, context);
        HttpEntity e = response.getEntity();
        if (e != null) {
            e.consumeContent();
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.