Package org.apache.http.message

Examples of org.apache.http.message.BasicStatusLine


        response.addHeader("Cache-Control", "max=10");

        Assert.assertTrue(policy.isResponseCacheable("GET", response));

        response = new BasicHttpResponse(
                new BasicStatusLine(HTTP_1_1, HttpStatus.SC_OK, ""));
        response.setHeader("Date", formatDate(new Date()));
        response.addHeader("Cache-Control", "no-transform");
        response.setHeader("Content-Length", "0");

        Assert.assertTrue(policy.isResponseCacheable("GET", response));
View Full Code Here


        Assert.assertTrue(policy.isResponseCacheable("GET", response));
    }

    @Test
    public void testIsGetWithout200Cacheable() {
        HttpResponse response = new BasicHttpResponse(new BasicStatusLine(HTTP_1_1,
                HttpStatus.SC_NOT_FOUND, ""));

        Assert.assertFalse(policy.isResponseCacheable("GET", response));

        response = new BasicHttpResponse(new BasicStatusLine(HTTP_1_1,
                HttpStatus.SC_GATEWAY_TIMEOUT, ""));

        Assert.assertFalse(policy.isResponseCacheable("GET", response));
    }
View Full Code Here

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            response.setStatusLine(new BasicStatusLine(
                    HttpVersion.HTTP_1_1,
                    HttpStatus.SC_UNAUTHORIZED,
                    "Authentication Required"));
            response.setHeader("Connection", "Keep-Alive");
            response.setHeader(HttpHeaders.WWW_AUTHENTICATE, "NTLM");
View Full Code Here

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            response.setStatusLine(new BasicStatusLine(
                    HttpVersion.HTTP_1_1,
                    HttpStatus.SC_UNAUTHORIZED,
                    "Authentication Required"));
            response.setHeader("Connection", "Keep-Alive");
            if (!request.containsHeader(HttpHeaders.AUTHORIZATION)) {
View Full Code Here

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            response.setStatusLine(new BasicStatusLine(
                    HttpVersion.HTTP_1_1,
                    HttpStatus.SC_UNAUTHORIZED,
                    "Authentication Required"));
            response.setHeader("Connection", "Keep-Alive");
            response.setHeader(HttpHeaders.WWW_AUTHENTICATE, authenticateHeaderValue);
View Full Code Here

        statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null);
        assertEquals("HTTP/1.1 200", statusline.toString());
    }
   
    public void testFormatting() throws Exception {
        StatusLine statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        String s = BasicStatusLine.format(statusline);
        assertEquals("HTTP/1.1 200 OK", s);
        statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null);
        s = BasicStatusLine.format(statusline);
        assertEquals("HTTP/1.1 200 ", s);
        // compare with "testParseSuccess" above: trailing space is correct
    }
View Full Code Here

        // compare with "testParseSuccess" above: trailing space is correct
    }
   
    public void testFormattingInvalidInput() throws Exception {
        try {
            BasicStatusLine.format(null, new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"));
            fail("IllegalArgumentException should habe been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
View Full Code Here

     */
    private final static HttpResponse createResponse(HttpVersion version,
                                                     int status,
                                                     String message) {

        StatusLine statusline = new BasicStatusLine(version, status, message);
        HttpResponse response = new BasicHttpResponse(statusline);

        return response;

    } // createResponse/empty
View Full Code Here

        if (ver == null) {
            throw new IllegalArgumentException("HTTP version may not be null");
        }
        final Locale loc      = determineLocale(context);
        final String reason   = reasonCatalog.getReason(status, loc);
        StatusLine statusline = new BasicStatusLine(ver, status, reason);
        return new BasicHttpResponse(statusline, reasonCatalog, loc);
    }
View Full Code Here


    // ----------------------------------------------------------- Test Methods

    public void testConstructor() {
        StatusLine statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        assertEquals(HttpVersion.HTTP_1_1, statusline.getHttpVersion());
        assertEquals(HttpStatus.SC_OK, statusline.getStatusCode());
        assertEquals("OK", statusline.getReasonPhrase());
    }
View Full Code Here

TOP

Related Classes of org.apache.http.message.BasicStatusLine

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.