Examples of HttpRequestHandler


Examples of org.apache.commons.httpclient.server.HttpRequestHandler

     * proxy fails to send 100 status code when expected. The client should
     * resume sending the request body after a defined timeout without having
     * received "continue" code.
     */
    public void testNoncompliantPostMethodString() throws Exception {
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 200 OK");
                out.println("Connection: close");
View Full Code Here

Examples of org.apache.commons.httpclient.server.HttpRequestHandler

    /**
     * Tests that a response status line containing \r and \n is handled.
     */
    public void testNoncompliantStatusLine() {
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 444 This status message contains\n"
                        + " a newline and a\r"
View Full Code Here

Examples of org.apache.commons.httpclient.server.HttpRequestHandler

     * Test if a response to HEAD method from non-compliant server that contains
     * an unexpected body content can be correctly redirected
     */
    public void testNoncompliantHeadWithResponseBody() throws Exception {
        final String body = "Test body";
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 200 OK");
                out.println("Connection: close");
View Full Code Here

Examples of org.apache.commons.httpclient.server.HttpRequestHandler

     * Test if a response to HEAD method from non-compliant server causes an
     * HttpException to be thrown
     */
    public void testNoncompliantHeadStrictMode() throws Exception {
        final String body = "Test body";
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 200 OK");
                out.println("Connection: close");
View Full Code Here

Examples of org.apache.commons.httpclient.server.HttpRequestHandler

    /**
     * Tests if client is able to handle gracefully malformed responses
     * that may not include response body.
     */
    public void testMalformed304Response() throws Exception {
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 304 OK");
                out.println("Connection: keep-alive");
View Full Code Here

Examples of org.apache.commons.httpclient.server.HttpRequestHandler

        assertEquals(HttpStatus.SC_NOT_MODIFIED, method.getStatusCode());
        method.getResponseBody();
    }

    public void testMalformed204Response() throws Exception {
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 204 OK");
                out.println("Connection: close");
View Full Code Here

Examples of org.apache.commons.httpclient.server.HttpRequestHandler

        assertTrue(connectionManager.getConection().isOpen());
    }
   
    public void testNoContentLength() throws Exception {
        // test with connection header
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 200 OK");
                out.println("Connection: keep-alive");
                out.println();
                out.println("12345");
                out.flush();
                return true;
            }
        });

        GetMethod method = new GetMethod("/");
        client.executeMethod(method);
        method.getResponseBodyAsString();
       
        assertFalse(connectionManager.getConection().isOpen());
       
        // test without connection header
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 200 OK");
                out.println();
View Full Code Here

Examples of org.apache.commons.httpclient.server.HttpRequestHandler

        assertEquals(5, method.getResponseContentLength());
    }

    public void testProxyNoContentLength() throws Exception {
        // test with proxy-connection header
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 200 OK");
                out.println("proxy-connection: keep-alive");
                out.println();
                out.println("12345");
                out.flush();
                return true;
            }
        });

        client.getHostConfiguration().setProxy(server.getLocalAddress(), server.getLocalPort());
        GetMethod method = new GetMethod("/");
        client.executeMethod(method);
        method.getResponseBodyAsString();
       
        assertFalse(connectionManager.getConection().isOpen());

        // test without proxy-connection header
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 200 OK");
                out.println();
View Full Code Here

Examples of org.apache.commons.httpclient.server.HttpRequestHandler

        assertEquals(null, method.getResponseHeader("bogus"));
    }
   
    public void testFoldedHeaders() throws Exception {
        final String body = "XXX\r\nYYY\r\nZZZ";
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 200 OK");
                out.println("Connection: close");
View Full Code Here

Examples of org.apache.commons.httpclient.server.HttpRequestHandler

        assertTrue(method.getResponseHeader("Content-Type").toString().indexOf("boundary") != -1);
    }


    public void testForceCloseConnection() throws Exception {
        this.server.setRequestHandler(new HttpRequestHandler() {
            public boolean processRequest(SimpleHttpServerConnection conn,
                    SimpleRequest request) throws IOException {
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 200 OK");
                out.println("Content-Type: garbage");
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.