Issue-953 Make sure that port is set when modifying headers

This commit is contained in:
vijaykiran 2012-06-01 22:16:04 +02:00 committed by Adrian Cole
parent cffcd29efc
commit 7fadf8b08b
2 changed files with 10 additions and 2 deletions

View File

@ -65,7 +65,11 @@ public class BindAsHostPrefixIfConfigured implements Binder {
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
if (isVhostStyle) {
request = bindAsHostPrefix.bindToRequest(request, payload);
return ModifyRequest.replaceHeader(request, HttpHeaders.HOST, request.getEndpoint().getHost());
String host = request.getEndpoint().getHost();
if (request.getEndpoint().getPort() != -1) {
host += ":" + request.getEndpoint().getPort();
}
return ModifyRequest.replaceHeader(request, HttpHeaders.HOST, host);
} else {
UriBuilder builder = uriBuilderProvider.get().uri(request.getEndpoint());
StringBuilder path = new StringBuilder(Strings2.urlEncode(request.getEndpoint().getPath(), S3AsyncClient.class

View File

@ -85,8 +85,12 @@ public class RedirectionRetryHandler implements HttpRetryHandler {
}
if (currentRequest.getFirstHeaderOrNull(HOST) != null && redirectionUrl.getHost() != null) {
String host = redirectionUrl.getHost();
if (redirectionUrl.getPort() != -1) {
host += ":" + redirectionUrl.getPort();
}
command.setCurrentRequest(ModifyRequest.replaceHeader(currentRequest, HOST,
singletonList(redirectionUrl.getHost())).toBuilder().endpoint(redirectionUrl).build());
singletonList(host)).toBuilder().endpoint(redirectionUrl).build());
} else {
command.setCurrentRequest(currentRequest.toBuilder().endpoint(redirectionUrl).build());
}