### Question:
HttpClient { public HttpResponse execute(HttpRequest request) throws IOException { HttpURLConnection urlConn = createConnection(request); urlConn.connect(); HttpHeaders headers = new HttpHeaders(urlConn.getHeaderFields()); HttpRespStatus status = HttpRespStatus.valueOf(urlConn.getResponseCode()); if (SUCCESS.contains(status.code())) { return new HttpResponse(status, headers, toBytes(urlConn.getInputStream())); } else { return new HttpResponse(status, headers, toBytes(urlConn.getErrorStream())); } } HttpClient(Builder builder); HttpResponse execute(HttpRequest request);  }### Answer:
@Test public void testGet() { HttpRequest req = new HttpRequest.Builder() .url("http: .get() .build(); try { HttpResponse resp = httpClient.execute(req); HttpHeaders headers = resp.getHeaders(); System.out.println("Status=" + resp.getStatus()); System.out.println("Connection=" + headers.get("Connection")); System.out.println(resp.getBodyString()); } catch (Exception e) { e.printStackTrace(); } }
@Test public void testPost() { Map<String, List<String>> params = MapUtils.createHashMap(2); params.put("db", Collections.singletonList("http")); HttpRequest req = new HttpRequest.Builder() .url("localhost:8686/write") .params(params) .post("cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000\n" + "cpu_load_short,host=server02,region=us-west value=0.96 1434055562000000000") .build(); for (int i = 0; i < 10; i++) { try { HttpResponse resp = httpClient.execute(req); Assert.assertEquals(OK, resp.getStatus()); Assert.assertEquals(RESPONSE_BODY, resp.getBodyString()); } catch (Exception e) { e.printStackTrace(); } } }