HttpParams params = new BasicHttpParams();
params.setParameter("http.default-headers", headers);
HttpClient httpclient = new DefaultHttpClient(params);
HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/");
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) {
assertTrue(response.getFirstHeader(header) != null);
}
assertEquals(expectedPayload, convertStreamToString(response.getEntity().getContent()).trim());
assertEquals(expectedPayload.length()+"", response.getFirstHeader("Content-Length").getValue());
}