Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.GetMethod.execute()


        String headers1 = "HTTP/1.1 200 OK\r\n"
                       +"Content-Length: 5\r\n";
        conn.addResponse(headers1, body);
        conn.open();
        GetMethod httpget = new GetMethod("/");
        httpget.execute(new HttpState(), conn);
        assertEquals(CHARSET_DEFAULT, httpget.getResponseCharSet());
        conn.close();
       
        httpget = new GetMethod("/");
        String headers2 = "HTTP/1.1 200 OK\r\n"
View Full Code Here


        String headers2 = "HTTP/1.1 200 OK\r\n"
                       +"Content-Type: text/plain\r\n"
                       +"Content-Length: 5\r\n";
        conn.addResponse(headers2, body);
        conn.open();
        httpget.execute(new HttpState(), conn);
        assertEquals(CHARSET_DEFAULT, httpget.getResponseCharSet());
        conn.close();

        httpget = new GetMethod("/");
        String headers3 = "HTTP/1.1 200 OK\r\n"
View Full Code Here

        String headers3 = "HTTP/1.1 200 OK\r\n"
                       +"Content-Type: text/plain; charset=" + CHARSET_UTF8 + "\r\n"
                       +"Content-Length: 5\r\n";
        conn.addResponse(headers3, body);
        conn.open();
        httpget.execute(new HttpState(), conn);
        assertEquals(CHARSET_UTF8, httpget.getResponseCharSet());
        conn.close();
    }

View Full Code Here

                       +"Content-Length: 1\r\n";
        String body = "0a\r\n1234567890\r\n3\r\n123\r\n0\r\n";
        conn.addResponse(headers, body);
        conn.open();
        HttpMethodBase method = new GetMethod("/");
        method.execute(new HttpState(), conn);
        String responseBody = method.getResponseBodyAsString();
        // verify that the connection was closed.
        conn.assertNotOpen();
        assertEquals("1234567890123", responseBody);
    }
View Full Code Here

                       +"Content-Length: 0\r\n";
        String body = "";
        conn.addResponse(headers, body);
        conn.open();
        HttpMethodBase method = new GetMethod("/");
        method.execute(new HttpState(), conn);

        String response = method.getResponseBodyAsString();
        assertNull(response);
    }
View Full Code Here

                       +"Content-Length: 0\r\n";
        String body = "";
        conn.addResponse(headers, body);
        conn.open();
        HttpMethodBase method = new GetMethod("/");
        method.execute(new HttpState(), conn);

        byte[] response = method.getResponseBody();
        assertNull(response);
    }
View Full Code Here

        conn.addResponse(headers, "");
        conn.setProxyHost("proxy");
        conn.setProxyPort(1);
        GetMethod method = new GetMethod("/");
        method.execute(new HttpState(), conn);
        method.getResponseBodyAsString();
       
        assertFalse(conn.isOpen());
       
        conn = new SimpleHttpConnection();
View Full Code Here

        conn.addResponse(headers, "");
        conn.setProxyHost("proxy");
        conn.setProxyPort(1);
        method = new GetMethod("/");
        method.execute(new HttpState(), conn);
        method.getResponseBodyAsString();
       
        assertTrue(conn.isOpen());       
    }
View Full Code Here

            + "Connection: close\r\n"
            + "\r\n";

        conn.addResponse(headers, "");
        GetMethod method = new GetMethod("/");
        method.execute(new HttpState(), conn);
        method.getResponseBodyAsString();
       
        assertFalse(conn.isOpen());

        conn = new SimpleHttpConnection();
View Full Code Here

            + "Content-Length: 0\r\n"
            +"\r\n";

        conn.addResponse(headers, "");
        method = new GetMethod("/");
        method.execute(new HttpState(), conn);
        method.getResponseBodyAsString();
       
        assertTrue(conn.isOpen());
    }
   
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.