mirror of https://github.com/apache/jclouds.git
Issue-953 Make sure that port is set when modifying headers
This commit is contained in:
parent
cffcd29efc
commit
7fadf8b08b
|
@ -65,7 +65,11 @@ public class BindAsHostPrefixIfConfigured implements Binder {
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
|
||||||
if (isVhostStyle) {
|
if (isVhostStyle) {
|
||||||
request = bindAsHostPrefix.bindToRequest(request, payload);
|
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 {
|
} else {
|
||||||
UriBuilder builder = uriBuilderProvider.get().uri(request.getEndpoint());
|
UriBuilder builder = uriBuilderProvider.get().uri(request.getEndpoint());
|
||||||
StringBuilder path = new StringBuilder(Strings2.urlEncode(request.getEndpoint().getPath(), S3AsyncClient.class
|
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) {
|
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,
|
command.setCurrentRequest(ModifyRequest.replaceHeader(currentRequest, HOST,
|
||||||
singletonList(redirectionUrl.getHost())).toBuilder().endpoint(redirectionUrl).build());
|
singletonList(host)).toBuilder().endpoint(redirectionUrl).build());
|
||||||
} else {
|
} else {
|
||||||
command.setCurrentRequest(currentRequest.toBuilder().endpoint(redirectionUrl).build());
|
command.setCurrentRequest(currentRequest.toBuilder().endpoint(redirectionUrl).build());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue