Examples of BasicStatusLine


Examples of org.apache.http.message.BasicStatusLine

  }

  @Test
  public void testCopyHttpResponse() {
    HttpResponse targetResponse = new BasicHttpResponse(
      new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
   
    targetResponse.setHeader("Transfer-Encoding", "gzip");
    targetResponse.setHeader("Content-Length", "123456");
    targetResponse.setHeader("Content-Type", "text/html");
    targetResponse.setHeader("Host", "tamacat.org");

    HttpResponse response = new BasicHttpResponse(
        new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
    response.setHeader("Set-Cookie", "key1=value1; domain=192.168.1.1");

    ReverseUtils.copyHttpResponse(targetResponse, response);
   
    assertNull(response.getFirstHeader("Transfer-Encoding"));
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

    serviceUrl.setHost(new URL("http://localhost/examples/servlets"));
    ReverseUrl reverseUrl = new DefaultReverseUrl(serviceUrl);
    reverseUrl.setReverse(new URL("http://localhost:8080/examples/"));
   
    HttpResponse response = new BasicHttpResponse(
        new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 302, "Moved Temporarily"))
    response.setHeader("Location", "http://localhost:8080/examples/servlets/");
    ReverseUtils.rewriteLocationHeader(null, response, reverseUrl);
    assertEquals("http://localhost/examples/servlets/",
      response.getFirstHeader("Location").getValue()
    );
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

    serviceUrl.setHost(new URL("http://localhost/examples/servlets"));
    ReverseUrl reverseUrl = new DefaultReverseUrl(serviceUrl);
    reverseUrl.setReverse(new URL("http://localhost:8080/examples/"));
   
    HttpResponse response = new BasicHttpResponse(
        new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 302, "Moved Temporarily"))
    response.setHeader("Content-Location", "http://localhost/examples/servlets/");
    ReverseUtils.rewriteContentLocationHeader(null, response, reverseUrl);
    assertEquals("http://localhost/examples/servlets/",
      response.getFirstHeader("Content-Location").getValue()
    );
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

   
    HttpRequest request = new BasicHttpRequest("GET", "/examples/servlets");
    request.setHeader("Host", "www.example.com");
   
    HttpResponse response = new BasicHttpResponse(
        new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"))
    response.setHeader("Set-Cookie", "key1=value1; domain=192.168.1.1");
    ReverseUtils.rewriteSetCookieHeader(request, response, reverseUrl);
   
    assertEquals("www.example.com",
      HeaderUtils.getCookieValue(
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

     * @return The {@link HttpResponse} that is the error generated
     */
    public HttpResponse getErrorForRequest(final RequestProtocolError errorCheck) {
        switch (errorCheck) {
            case BODY_BUT_NO_LENGTH_ERROR:
                return new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1,
                        HttpStatus.SC_LENGTH_REQUIRED, ""));

            case WEAK_ETAG_AND_RANGE_ERROR:
                return new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1,
                        HttpStatus.SC_BAD_REQUEST, "Weak eTag not compatible with byte range"));

            case WEAK_ETAG_ON_PUTDELETE_METHOD_ERROR:
                return new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1,
                        HttpStatus.SC_BAD_REQUEST,
                        "Weak eTag not compatible with PUT or DELETE requests"));

            case NO_CACHE_DIRECTIVE_WITH_FIELD_NAME:
                return new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1,
                        HttpStatus.SC_BAD_REQUEST,
                        "No-Cache directive MUST NOT include a field name"));

            default:
                throw new IllegalStateException(
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

    @Before
    public void setUp() {
        now = new Date();
        elevenSecondsAgo = new Date(now.getTime() - 11 * 1000L);
        nineSecondsAgo = new Date(now.getTime() - 9 * 1000L);
        statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1,
                HttpStatus.SC_OK, "OK");
        mockResource = createNiceMock(Resource.class);
    }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

*/
public class TestBasicResponseHandler {

    @Test
    public void testSuccessfulResponse() throws Exception {
        final StatusLine sl = new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK");
        final HttpResponse response = Mockito.mock(HttpResponse.class);
        final HttpEntity entity = new StringEntity("stuff");
        Mockito.when(response.getStatusLine()).thenReturn(sl);
        Mockito.when(response.getEntity()).thenReturn(entity);

View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

    public void testUnsuccessfulResponse() throws Exception {
        final InputStream instream = Mockito.mock(InputStream.class);
        final HttpEntity entity = Mockito.mock(HttpEntity.class);
        Mockito.when(entity.isStreaming()).thenReturn(true);
        Mockito.when(entity.getContent()).thenReturn(instream);
        final StatusLine sl = new BasicStatusLine(HttpVersion.HTTP_1_1, 404, "Not Found");
        final HttpResponse response = Mockito.mock(HttpResponse.class);
        Mockito.when(response.getStatusLine()).thenReturn(sl);
        Mockito.when(response.getEntity()).thenReturn(entity);

        final BasicResponseHandler handler = new BasicResponseHandler();
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

    }

    public static HttpCacheEntry makeCacheEntry(final Date requestDate,
            final Date responseDate, final Header[] headers, final byte[] bytes,
            final Map<String,String> variantMap) {
        final StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        return new HttpCacheEntry(requestDate, responseDate, statusLine, headers, new HeapResource(bytes), variantMap);
    }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

        tenSecondsFromNow = new Date(now.getTime() + 10 * 1000L);

        policy = new ResponseCachingPolicy(0, true, false);
        request = new BasicHttpRequest("GET","/",HTTP_1_1);
        response = new BasicHttpResponse(
                new BasicStatusLine(HTTP_1_1, HttpStatus.SC_OK, ""));
        response.setHeader("Date", formatDate(new Date()));
        response.setHeader("Content-Length", "0");
    }
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.