Examples of BasicStatusLine


Examples of org.apache.http.message.BasicStatusLine

    }

    public void testNoKeepAliveHeader() throws Exception {
        HttpContext context = new BasicHttpContext(null);
        HttpResponse response = new BasicHttpResponse(
                new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"));
        ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
        long d = keepAliveStrat.getKeepAliveDuration(response, context);
        assertEquals(-1, d);
    }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

    }

    public void testEmptyKeepAliveHeader() throws Exception {
        HttpContext context = new BasicHttpContext(null);
        HttpResponse response = new BasicHttpResponse(
                new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"));
        response.addHeader("Keep-Alive", "timeout, max=20");
        ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
        long d = keepAliveStrat.getKeepAliveDuration(response, context);
        assertEquals(-1, d);
    }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

    }

    public void testInvalidKeepAliveHeader() throws Exception {
        HttpContext context = new BasicHttpContext(null);
        HttpResponse response = new BasicHttpResponse(
                new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"));
        response.addHeader("Keep-Alive", "timeout=whatever, max=20");
        ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
        long d = keepAliveStrat.getKeepAliveDuration(response, context);
        assertEquals(-1, d);
    }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

    }

    public void testKeepAliveHeader() throws Exception {
        HttpContext context = new BasicHttpContext(null);
        HttpResponse response = new BasicHttpResponse(
                new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"));
        response.addHeader("Keep-Alive", "timeout=300, max=20");
        ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
        long d = keepAliveStrat.getKeepAliveDuration(response, context);
        assertEquals(300000, d);
    }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

        return new TestSuite(TestHttpOptions.class);
    }

    public void testMultipleAllows() {
        ProtocolVersion proto = new ProtocolVersion("HTTP", 1, 1);
        BasicStatusLine line = new BasicStatusLine(proto, 200, "test reason");
        BasicHttpResponse resp = new BasicHttpResponse(line);
        resp.addHeader("Allow", "POST");
        resp.addHeader("Allow", "GET");

        HttpOptions opt = new HttpOptions();
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

                } else if (reqDotVersion == 1) {
                     version = new HttpVersion(1, 1);
                }
                // and if not any of these, trust that a Null version will
                // cause an appropriate error
        callback.handleStatusLine(new BasicStatusLine(version, statusCode, "Status set by browsermob-proxy"));
        // No mechanism to look up the response text by status code,
        // so include a notification that this is a synthetic error code.
            } else {
                response = httpClient.execute(method, ctx);
                statusLine = response.getStatusLine();
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

  @Test
  public void testGetPrintErrorPage() {
    VelocityErrorPage template = new VelocityErrorPage(props);
    HttpRequest request = new BasicHttpRequest("GET", "http://localhost/test");
    HttpResponse response = new BasicHttpResponse(
        new BasicStatusLine(new ProtocolVersion("HTTP",1,1), 404, "Not Found"));
    HttpException exception = new NotFoundException();
    String page = template.getErrorPage(request, response, exception);
    assertNotNull(page);
  }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

  public static HttpRequest createHttpRequest(String method, String uri) {
    return new BasicHttpRequest(method, uri);
  }
 
  public static HttpResponse createHttpResponse(int status, String reason) {
    StatusLine statusLine = new BasicStatusLine(
      new ProtocolVersion("HTTP",1,1), status, reason);
    return new BasicHttpResponse(statusLine);
  }
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.