mirror of https://github.com/apache/jclouds.git
Merge pull request #660 from vijaykiran/issue-953
Issue-953 Make sure that port is set when modifying headers
This commit is contained in:
commit
20f4586be1
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue