Examples of StatusLine


Examples of org.apache.http.StatusLine


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

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

Examples of org.apache.http.StatusLine

            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException e) { /* expected */ }
    }

    public void testToString() throws Exception {
        StatusLine statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        assertEquals("HTTP/1.1 200 OK", statusline.toString());
        statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null);
        // toString uses default formatting, hence the trailing space
        assertEquals("HTTP/1.1 200 ", statusline.toString());
    }
View Full Code Here

Examples of org.apache.http.StatusLine

        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

Examples of org.apache.http.StatusLine

    }


   
    public void testSLFormatting() throws Exception {
        StatusLine statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        String s = BasicLineFormatter.formatStatusLine(statusline, null);
        assertEquals("HTTP/1.1 200 OK", s);
        statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null);
        s = BasicLineFormatter.formatStatusLine(statusline, null);
        assertEquals("HTTP/1.1 200 ", s);
View Full Code Here

Examples of org.apache.http.StatusLine

    @Override
  protected HttpMessage createMessage(final CharArrayBuffer buffer)
            throws HttpException, ParseException {
        ParserCursor cursor = new ParserCursor(0, buffer.length());
        StatusLine statusline = lineParser.parseStatusLine(buffer, cursor);
        return this.responseFactory.newHttpResponse(statusline, null);
    }
View Full Code Here

Examples of org.apache.http.StatusLine

        if (i == -1) {
            throw new NoHttpResponseException("The target server failed to respond");
        }
        //create the status line from the status string
        ParserCursor cursor = new ParserCursor(0, this.lineBuf.length());
        StatusLine statusline = lineParser.parseStatusLine(this.lineBuf, cursor);
        return this.responseFactory.newHttpResponse(statusline, null);
    }
View Full Code Here

Examples of org.apache.http.StatusLine

                        " failed to respond with a valid HTTP response");
            }
            count++;
        } while(true);
        //create the status line from the status string
        StatusLine statusline = StatusLine.parse(this.buffer, 0, this.buffer.length());
        HttpResponse response = this.responsefactory.newHttpResponse(statusline);
        response.getParams().setDefaults(params);
        return response;
    }
View Full Code Here

Examples of org.apache.http.StatusLine

   
    public void setStatusCode(int code) {
        if (code < 0) {
            throw new IllegalArgumentException("Status line may not be null");
        }
        this.statusline = new StatusLine(
                HttpProtocolParams.getVersion(getParams()),
                code, HttpStatus.getStatusText(code));
    }
View Full Code Here

Examples of org.apache.http.StatusLine

    public HttpResponse newHttpResponse(final HttpVersion ver, final int status) {
        if (ver == null) {
            throw new IllegalArgumentException("HTTP version may not be null");
        }
        StatusLine statusline = new StatusLine(ver, status, HttpStatus.getStatusText(status));
        return new BasicHttpResponse(statusline);
    }
View Full Code Here

Examples of org.apache.http.StatusLine

            throws HttpException, IOException {
        HttpVersion ver = request.getRequestLine().getHttpVersion();
        if (ver.lessEquals(HttpVersion.HTTP_1_1)) {
            response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
        } else {
            response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_IMPLEMENTED));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.