Package org.apache.commons.httpclient.server

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


                method.shouldCloseConnection(connectionManager.getConection()));
        assertTrue("Connection should be force-closed", method.isConnectionCloseForced());
    }
   
    public void testForceCloseConnection2() 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


        assertFalse("Connection should NOT be closed", method.isConnectionCloseForced());
    }
   
    public void testNoContent() 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 204 NO CONTENT");
                out.println();
                out.flush();
                return true;
            }
        });

        GetMethod method = new GetMethod("/");
        client.executeMethod(method);
        method.getResponseBodyAsString();

        assertTrue(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 204 NO CONTENT");
                out.println("Connection: keep-alive");
View Full Code Here

        }
        assertTrue(connman.getConection().isOpen());
    }

    public void testRequestConnClose() throws Exception {
        this.server.setRequestHandler(new HttpRequestHandler() {
          
            public boolean processRequest(
                    final SimpleHttpServerConnection conn,
                    final SimpleRequest request) throws IOException {
View Full Code Here

        }
        assertTrue(connman.getConection().isOpen());
    }

    public void testRequestConnClose() throws Exception {
        this.server.setRequestHandler(new HttpRequestHandler() {
          
            public boolean processRequest(
                    final SimpleHttpServerConnection conn,
                    final SimpleRequest request) throws IOException {
View Full Code Here

     * 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

    /**
     * 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

     * 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

     * 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

    /**
     * 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 {
                conn.setSocketTimeout(20000);
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 304 OK");
View Full Code Here

        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 {
                conn.setSocketTimeout(20000);
                ResponseWriter out = conn.getWriter();
                out.println("HTTP/1.1 204 OK");
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.server.HttpRequestHandler

Copyright © 2018 www.massapicom. 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.