Package org.apache.http

Examples of org.apache.http.ProtocolVersion


    HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/static_file_handler");
    HttpResponse response = httpclient.execute(httpget);

    assertNotNull(response);
    assertEquals(200, response.getStatusLine().getStatusCode());
    assertEquals(new ProtocolVersion("HTTP", 1, 1), response.getStatusLine().getProtocolVersion());
    assertEquals("OK", response.getStatusLine().getReasonPhrase());
    assertEquals(4, response.getAllHeaders().length);
    assertEquals("8", response.getFirstHeader("Content-Length").getValue());
  }
View Full Code Here


    HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/keyvalue");
    HttpResponse response = httpclient.execute(httpget);

    assertNotNull(response);
    assertEquals(200, response.getStatusLine().getStatusCode());
    assertEquals(new ProtocolVersion("HTTP", 1, 1), response.getStatusLine().getProtocolVersion());
    assertEquals("OK", response.getStatusLine().getReasonPhrase());
    assertEquals(5, response.getAllHeaders().length);
    assertEquals("7", response.getFirstHeader("Content-Length").getValue());
    assertEquals("kickass", convertStreamToString(response.getEntity().getContent()).trim());
  }
View Full Code Here

    HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/450kb_body");
    HttpResponse response = httpclient.execute(httpget);

    assertNotNull(response);
    assertEquals(200, response.getStatusLine().getStatusCode());
    assertEquals(new ProtocolVersion("HTTP", 1, 1), response.getStatusLine().getProtocolVersion());
    assertEquals("OK", response.getStatusLine().getReasonPhrase());
    assertEquals(5, response.getAllHeaders().length);
    //assertEquals(450*1024, Integer.parseInt(response.getFirstHeader("Content-Length").getValue())/8);
    //assertEquals(450*1024, _450KBResponseEntityRequestHandlr.entity.getBytes(Charsets.UTF_8).length);
    String payLoad = convertStreamToString(response.getEntity().getContent()).trim();
View Full Code Here

    httppost.setEntity(new StringEntity(body))// HTTP 1.1 says that the default charset is ISO-8859-1
    HttpResponse response = httpclient.execute(httppost)
   
    assertNotNull(response);
    assertEquals(200, response.getStatusLine().getStatusCode());
    assertEquals(new ProtocolVersion("HTTP", 1, 1), response.getStatusLine().getProtocolVersion());
    assertEquals("OK", response.getStatusLine().getReasonPhrase());
    assertEquals(5, response.getAllHeaders().length);
    String payLoad = convertStreamToString(response.getEntity().getContent()).trim();
    assertEquals(body, payLoad);
  }
View Full Code Here

    httpget.setHeader("user", "Roger Schildmeijer");
    HttpResponse response = httpclient.execute(httpget);

    assertNotNull(response);
    assertEquals(200, response.getStatusLine().getStatusCode());
    assertEquals(new ProtocolVersion("HTTP", 1, 1), response.getStatusLine().getProtocolVersion());
    assertEquals("OK", response.getStatusLine().getReasonPhrase());
    assertEquals(5, response.getAllHeaders().length);
    String payLoad = convertStreamToString(response.getEntity().getContent()).trim();
    assertEquals("Roger Schildmeijer", payLoad);
  }
View Full Code Here

    httpget.setHeader("wrong_header", "Roger Schildmeijer");
    HttpResponse response = httpclient.execute(httpget);

    assertNotNull(response);
    assertEquals(403, response.getStatusLine().getStatusCode());
    assertEquals(new ProtocolVersion("HTTP", 1, 1), response.getStatusLine().getProtocolVersion());
    assertEquals("Forbidden", response.getStatusLine().getReasonPhrase());
    assertEquals(5, response.getAllHeaders().length);
    String payLoad = convertStreamToString(response.getEntity().getContent()).trim();
    assertEquals("Authentication failed", payLoad);
  }
View Full Code Here

    HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/query_params?key1=value1&key2=value2");
    HttpResponse response = httpclient.execute(httpget);
    List<String> expectedHeaders = Arrays.asList(new String[] {"Server", "Date", "Content-Length", "Etag", "Connection"});

    assertEquals(200, response.getStatusLine().getStatusCode());
    assertEquals(new ProtocolVersion("HTTP", 1, 1), response.getStatusLine().getProtocolVersion());
    assertEquals("OK", response.getStatusLine().getReasonPhrase());
   
    assertEquals(expectedHeaders.size(), response.getAllHeaders().length);

    for (String header : expectedHeaders) {
View Full Code Here

        BasicHttpEntity entity = new BasicHttpEntity();
        entity.setContent(bais);
        entity.setContentLength(0);
        entity.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);

        BasicHttpResponse response = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1), 400, "Exception: "
                + errorMessage);
        response.setEntity(entity);

        response.addHeader("Content-Disposition", "attachment; filename=error");
View Full Code Here

       
        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
            String uri = request.getRequestLine().getUri();
            if (uri.startsWith("/circular-oldlocation")) {
                response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
                response.addHeader(new BasicHeader("Location", "/circular-location2"));
            } else if (uri.startsWith("/circular-location2")) {
View Full Code Here

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
            String uri = request.getRequestLine().getUri();
            if (uri.equals("/oldlocation/")) {
                response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
                response.addHeader(new BasicHeader("Location", "/relativelocation/"));
            } else if (uri.equals("/relativelocation/")) {
View Full Code Here

TOP

Related Classes of org.apache.http.ProtocolVersion

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.