Package org.apache.commons.httpclient.server

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


  protected void setUp() throws Exception {
    super.setUp();
    tmpFile = File.createTempFile("ECFTest", "");
    server = new SimpleServer(getName());
    SimpleHttpServer simple = server.getSimpleHttpServer();
    simple.setRequestHandler(new HttpRequestHandler() {

      public boolean processRequest(SimpleHttpServerConnection conn,
          SimpleRequest request) throws IOException {
        trace("Responding to request "
            + request.getRequestLine());
View Full Code Here


      }
    };

    final SimpleServer server = new SimpleServer(getName());
    SimpleHttpServer simple = server.getSimpleHttpServer();
    simple.setRequestHandler(new HttpRequestHandler() {

      public boolean processRequest(SimpleHttpServerConnection conn,
          SimpleRequest request) throws IOException {
        trace("Not responding to request " + request.getRequestLine());
        return stalledInRequestHandler(doCancel);
View Full Code Here

      }
    };

    final SimpleServer server = new SimpleServer(getName());
    SimpleHttpServer simple = server.getSimpleHttpServer();
    simple.setRequestHandler(new HttpRequestHandler() {

      public boolean processRequest(SimpleHttpServerConnection conn,
          SimpleRequest request) throws IOException {
        trace("Responding to request but never provide full body"
            + request.getRequestLine());
View Full Code Here

      }
    };

    final SimpleServer server = new SimpleServer(getName());
    SimpleHttpServer simple = server.getSimpleHttpServer();
    simple.setRequestHandler(new HttpRequestHandler() {

      public boolean processRequest(SimpleHttpServerConnection conn,
          SimpleRequest request) throws IOException {
        trace("Responding to request but never provide only 50% of body"
            + request.getRequestLine());
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(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

        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

        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

        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

                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

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.