Examples of keepAlive()


Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()

    public void testHTTP10Default() throws Exception {
        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK");
        HttpResponse response = new BasicHttpResponse(statusline);

        ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
        assertFalse(s.keepAlive(response));
    }
   
    public void testHTTP11Default() throws Exception {
        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_1, 200, "OK");
        HttpResponse response = new BasicHttpResponse(statusline);
View Full Code Here

Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()

    public void testHTTP11Default() throws Exception {
        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_1, 200, "OK");
        HttpResponse response = new BasicHttpResponse(statusline);

        ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
        assertTrue(s.keepAlive(response));
    }

    public void testFutureHTTP() throws Exception {
        StatusLine statusline = new StatusLine(new HttpVersion(3, 45), 200, "OK");
        HttpResponse response = new BasicHttpResponse(statusline);
View Full Code Here

Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()

    public void testFutureHTTP() throws Exception {
        StatusLine statusline = new StatusLine(new HttpVersion(3, 45), 200, "OK");
        HttpResponse response = new BasicHttpResponse(statusline);

        ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
        assertTrue(s.keepAlive(response));
    }
   
    public void testBrokenConnectionDirective1() throws Exception {
        // Use HTTP 1.0
        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK");
View Full Code Here

Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()

        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK");
        HttpResponse response = new BasicHttpResponse(statusline);
        response.addHeader(new Header("Connection", "keep--alive"));

        ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
        assertFalse(s.keepAlive(response));
    }

    public void testBrokenConnectionDirective2() throws Exception {
        // Use HTTP 1.0
        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK");
View Full Code Here

Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()

        StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_0, 200, "OK");
        HttpResponse response = new BasicHttpResponse(statusline);
        response.addHeader(new Header("Connection", null));

        ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
        assertFalse(s.keepAlive(response));
    }
}
View Full Code Here

Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()

                System.out.println(">> Request URI: " + request.getRequestLine().getUri());
                HttpResponse response = httpexecutor.execute(request, conn, context);
                System.out.println("<< Response: " + response.getStatusLine());
                System.out.println(EntityUtils.toString(response.getEntity()));
                System.out.println("==============");
                if (!connStrategy.keepAlive(response, context)) {
                    conn.close();
                } else {
                    System.out.println("Connection kept alive...");
                }
            }
View Full Code Here

Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()

                System.out.println(">> Request URI: " + request.getRequestLine().getUri());
                HttpResponse response = httpexecutor.execute(request, conn, context);
                System.out.println("<< Response: " + response.getStatusLine());
                System.out.println(EntityUtils.toString(response.getEntity()));
                System.out.println("==============");
                if (!connStrategy.keepAlive(response, context)) {
                    conn.close();
                } else {
                    System.out.println("Connection kept alive...");
                }
            }
View Full Code Here

Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()

            HttpResponse response = state.getResponse();
            String method = request.getRequestLine().getMethod();
            int status = response.getStatusLine().getStatusCode();
            if (!(method.equalsIgnoreCase("CONNECT") && status < 300)) {
                ConnectionReuseStrategy connReuseStrategy = handler.getConnectionReuseStrategy();
                if (!connReuseStrategy.keepAlive(response, context)) {
                    conn.close();
                }
            }
        } else {
            conn.close();
View Full Code Here

Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()

            HttpRequest request1 = requestfactory.newHttpRequest("GET", "/");
            HttpResponse response1 = httpexec.execute(request1, conn);
            System.out.println("<< Response: " + response1.getStatusLine());
            System.out.println(EntityUtils.toString(response1.getEntity()));
            System.out.println("==============");
            if (connStrategy.keepAlive(response1)) {
                System.out.println("Connection kept alive...");
            } else {
                conn.close();
                System.out.println("Connection closed...");
            }
View Full Code Here

Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()

            HttpRequest request2 = requestfactory.newHttpRequest("GET", "/stuff");
            HttpResponse response2 = httpexec.execute(request2, conn);
            System.out.println("<< Response: " + response2.getStatusLine());
            System.out.println(EntityUtils.toString(response2.getEntity()));
            System.out.println("==============");
            if (connStrategy.keepAlive(response2)) {
                System.out.println("Connection kept alive...");
            } else {
                conn.close();
                System.out.println("Connection closed...");
            }
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.