@Override
    public ClientResponse apply(ClientRequest jerseyRequest) {
        try {
            final HttpUriRequest apacheRequest = buildApacheRequest(jerseyRequest);
            final CloseableHttpResponse apacheResponse = client.execute(apacheRequest);

            final String reasonPhrase = apacheResponse.getReasonPhrase();
            final Response.StatusType status = Statuses.from(apacheResponse.getCode(), reasonPhrase == null ? "" : reasonPhrase);

            final ClientResponse jerseyResponse = new ClientResponse(status, jerseyRequest);
            for (Header header : apacheResponse.getHeaders()) {
                jerseyResponse.getHeaders().computeIfAbsent(header.getName(), k -> new ArrayList<>())
                    .add(header.getValue());
            }

            final HttpEntity httpEntity = apacheResponse.getEntity();
            jerseyResponse.setEntityStream(httpEntity != null ? httpEntity.getContent() :
                    new ByteArrayInputStream(new byte[0]));

            return jerseyResponse;
        } catch (Exception e) {
            throw new ProcessingException(e);
        }
    }
@Test
    void multiple_headers_with_the_same_name_are_processed_successfully() throws Exception {

        final CloseableHttpClient client = mock(CloseableHttpClient.class);
        final DropwizardApacheConnector dropwizardApacheConnector = new DropwizardApacheConnector(client, null, false);
        final Header[] apacheHeaders = {
            new BasicHeader("Set-Cookie", "test1"),
            new BasicHeader("Set-Cookie", "test2")
        };

        final CloseableHttpResponse apacheResponse = mock(CloseableHttpResponse.class);
        when(apacheResponse.getCode()).thenReturn(200);
        when(apacheResponse.getReasonPhrase()).thenReturn("OK");
        when(apacheResponse.getHeaders()).thenReturn(apacheHeaders);
        when(client.execute(Mockito.any())).thenReturn(apacheResponse);

        final ClientRequest jerseyRequest = mock(ClientRequest.class);
        when(jerseyRequest.getUri()).thenReturn(URI.create("http://localhost"));
        when(jerseyRequest.getMethod()).thenReturn("GET");
        when(jerseyRequest.getHeaders()).thenReturn(new MultivaluedHashMap<>());

        final ClientResponse jerseyResponse = dropwizardApacheConnector.apply(jerseyRequest);

        assertThat(jerseyResponse.getStatus()).isEqualTo(apacheResponse.getCode());

    }