mirror of https://github.com/apache/jclouds.git
Resolves JCLOUDS-1261 by ensuring non-standard port numbers are in the host header that's used for the AWSv4 auth calculations.
This commit is contained in:
parent
5b2aca103e
commit
15d27da739
|
@ -73,8 +73,9 @@ public class Aws4SignerForAuthorizationHeader extends Aws4SignerBase {
|
||||||
|
|
||||||
Payload payload = request.getPayload();
|
Payload payload = request.getPayload();
|
||||||
|
|
||||||
// get host from request endpoint.
|
// get host & port from request endpoint.
|
||||||
String host = request.getEndpoint().getHost();
|
String host = request.getEndpoint().getHost();
|
||||||
|
int port = request.getEndpoint().getPort();
|
||||||
|
|
||||||
Date date = timestampProvider.get();
|
Date date = timestampProvider.get();
|
||||||
String timestamp = timestampFormat.format(date);
|
String timestamp = timestampFormat.format(date);
|
||||||
|
@ -119,6 +120,13 @@ public class Aws4SignerForAuthorizationHeader extends Aws4SignerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// host
|
// host
|
||||||
|
// if the port is defined and doesn't match the URI scheme
|
||||||
|
if (port != -1) {
|
||||||
|
if (("http".equalsIgnoreCase(request.getEndpoint().getScheme()) && port != 80) ||
|
||||||
|
("https".equalsIgnoreCase(request.getEndpoint().getScheme()) && port != 443)) {
|
||||||
|
host += ":" + port; // append the port number to the hostname
|
||||||
|
}
|
||||||
|
}
|
||||||
requestBuilder.replaceHeader(HttpHeaders.HOST, host);
|
requestBuilder.replaceHeader(HttpHeaders.HOST, host);
|
||||||
signedHeadersBuilder.put(HttpHeaders.HOST.toLowerCase(), host);
|
signedHeadersBuilder.put(HttpHeaders.HOST.toLowerCase(), host);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue