Package org.apache.commons.httpclient.server

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


        assertNotNull( "Response body is null.", method.getResponseBodyAsStream() );
    }

    public void testDuplicateConnection() throws Exception {
       
        this.server.setHttpService(new HttpService() {
            public boolean process(SimpleRequest request,
                    SimpleResponse response) throws IOException {
                response.setStatusLine(request.getRequestLine().getHttpVersion(), 200);
                response.addHeader(new Header("Connection", "close"));
                response.addHeader(new Header("Connection", "close"));
                return true;
            }
        });

        GetMethod method = new GetMethod("/");
        client.executeMethod(method);
        method.getResponseBodyAsString();
       
        assertFalse(connectionManager.getConection().isOpen());

        this.server.setHttpService(new HttpService() {
            public boolean process(SimpleRequest request,
                    SimpleResponse response) throws IOException {
                response.setStatusLine(HttpVersion.HTTP_1_0, 200);
                response.addHeader(new Header("Connection", "keep-alive"));
                response.addHeader(new Header("Connection", "keep-alive"));
View Full Code Here


       
        assertFalse(connectionManager.getConection().isOpen());
    }

    public void testInvalidContentLength1() throws Exception {
        this.server.setHttpService(new HttpService() {
            public boolean process(SimpleRequest request,
                    SimpleResponse response) throws IOException {
                response.setStatusLine(request.getRequestLine().getHttpVersion(), 200);
                response.addHeader(new Header("Content-Length", "5"));
                response.addHeader(new Header("Content-Length", "stuff"));
View Full Code Here

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

    public void testInvalidContentLength2() throws Exception {
        this.server.setHttpService(new HttpService() {
            public boolean process(SimpleRequest request,
                    SimpleResponse response) throws IOException {
                response.setStatusLine(request.getRequestLine().getHttpVersion(), 200);
                response.addHeader(new Header("Content-Length", "stuff"));
                response.addHeader(new Header("Content-Length", "5"));
View Full Code Here

       
        assertFalse(connectionManager.getConection().isOpen());
    }

    public void testNullHeaders() throws Exception {
        this.server.setHttpService(new HttpService() {
            public boolean process(SimpleRequest request,
                    SimpleResponse response) throws IOException {
                response.setStatusLine(request.getRequestLine().getHttpVersion(), 200);
                response.addHeader(new Header("Connection", "close"));
                response.setBodyString("XXX\r\nYYY\r\nZZZ");
View Full Code Here

TOP

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

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.