diff --git a/core/src/main/java/org/jclouds/http/TransformingHttpCommandImpl.java b/core/src/main/java/org/jclouds/http/TransformingHttpCommandImpl.java index 1d776d8704..af7d3e8e8a 100644 --- a/core/src/main/java/org/jclouds/http/TransformingHttpCommandImpl.java +++ b/core/src/main/java/org/jclouds/http/TransformingHttpCommandImpl.java @@ -25,6 +25,7 @@ package org.jclouds.http; import java.io.InputStream; import java.util.Collections; +import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -106,13 +107,15 @@ public class TransformingHttpCommandImpl implements TransformingHttpCommand * This also removes the Host header in order to avoid ssl problems. */ - public HttpRequest setHostAndPort(String host, int port) { + public HttpRequest setHostAndPort(String host, int port) { // TODO must unit test to ensure + // request is copied 100% UriBuilder builder = UriBuilder.fromUri(request.getEndpoint()); builder.host(host); builder.port(port); - Object oldEntity = request.getEntity(); - request = new HttpRequest(request.getMethod(), builder.build(), request.getHeaders()); - request.setEntity(oldEntity); + List oldFilters = request.getFilters(); + request = new HttpRequest(request.getMethod(), builder.build(), request.getHeaders(), request + .getEntity()); + request.getFilters().addAll(oldFilters); request.getHeaders().replaceValues(HttpHeaders.HOST, Collections.singletonList(host)); return request; }