Package org.sentinel.servers.http.protocol

Examples of org.sentinel.servers.http.protocol.HTTPRequestHeaders


    public static final String validInitialHeader = "GET /some/path HTTP/1.1";

    @Test
    public void testValidInitialHeader()
    {
        HTTPRequestHeaders headers = new HTTPRequestHeaders(validInitialHeader);
        assertEquals("GET", headers.getMethod());
        assertEquals("/some/path", headers.getPath());
        assertEquals("HTTP/1.1", headers.getVersion());
    }
View Full Code Here


    }
   
    @Test
    public void testMethod()
    {
        HTTPRequestHeaders headers = new HTTPRequestHeaders(validInitialHeader);
        headers.setMethod("POST");
        assertEquals("POST", headers.getMethod());
    }
View Full Code Here

    }
   
    @Test
    public void testPath()
    {
        HTTPRequestHeaders headers = new HTTPRequestHeaders(validInitialHeader);
        headers.setPath("/some/other/path");
        assertEquals("/some/other/path", headers.getPath());
    }
View Full Code Here

    }
   
    @Test
    public void testVersion()
    {
        HTTPRequestHeaders headers = new HTTPRequestHeaders(validInitialHeader);
        headers.setVersion("HTTP/1.0");
        assertEquals("HTTP/1.0", headers.getVersion());
    }
View Full Code Here

    }
   
    public HTTPResponse sendRequest(String path, String data) throws ClientException
    {
        // build the headers
        HTTPRequestHeaders headers = new HTTPRequestHeaders("GET " + path + " HTTP/1.1");
        headers.addOrReplace(new HTTPHeader("content-length", data.length()));

        // sent request
        byte[] result = sendRawRequest((headers.toString() + data).getBytes());

        // process response
        HTTPResponse response = HTTPResponse.parse(new String(result));
        return response;
    }
View Full Code Here

TOP

Related Classes of org.sentinel.servers.http.protocol.HTTPRequestHeaders

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.