ApacheUtils { public static HttpResponse createResponse(Request<?> request, HttpRequestBase method, org.apache.http.HttpResponse apacheHttpResponse, HttpContext context) throws IOException { HttpResponse httpResponse = new HttpResponse(request, method, context); if (apacheHttpResponse.getEntity() != null) { httpResponse.setContent(apacheHttpResponse.getEntity().getContent()); } httpResponse.setStatusCode(apacheHttpResponse.getStatusLine().getStatusCode()); httpResponse.setStatusText(apacheHttpResponse.getStatusLine().getReasonPhrase()); for (Header header : apacheHttpResponse.getAllHeaders()) { httpResponse.addHeader(header.getName(), header.getValue()); } return httpResponse; }  static boolean isRequestSuccessful(org.apache.http.HttpResponse response); static HttpResponse createResponse(Request<?> request,
                                        HttpRequestBase method,
                                        org.apache.http.HttpResponse apacheHttpResponse,
                                        HttpContext context); static HttpEntity newStringEntity(String s); static HttpEntity newBufferedHttpEntity(HttpEntity entity); static HttpClientContext newClientContext(HttpClientSettings settings,
                                                     Map<String, ? extends Object>
                                                             attributes); static void disableNormalizeUri(RequestConfig.Builder requestConfigBuilder); static CredentialsProvider newProxyCredentialsProvider(HttpClientSettings settings);  }
@Test public void createResponse_copiesAllHeaders() throws IOException { HttpResponse mockHttpResponse = mock(HttpResponse.class); List<Header> headers = new ArrayList<Header>(); headers.add(new BasicHeader("foo", "a")); headers.add(new BasicHeader("FOO", "b")); headers.add(new BasicHeader("fOO", "c")); when(mockHttpResponse.getStatusLine()).thenReturn( new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK")); when(mockHttpResponse.getAllHeaders()).thenReturn(headers.toArray(new Header[0])); com.amazonaws.http.HttpResponse response = ApacheUtils.createResponse(null, null, mockHttpResponse, null); assertArrayEquals(response.getAllHeaders().get("foo").toArray(), new String[] {"a", "b", "c"}); }