mirror of https://github.com/apache/jclouds.git
JCLOUDS-766: Check metadata and headers for MD5
Addresses AWSS3ClientLiveTest.testMultipartSynchronously test failures.
This commit is contained in:
parent
35c5d7ffc0
commit
8053abb530
|
@ -106,14 +106,17 @@ public class Aws4SignerForAuthorizationHeader extends Aws4SignerBase {
|
|||
}
|
||||
|
||||
// Content MD5
|
||||
String contentMD5 = request.getFirstHeaderOrNull(CONTENT_MD5);
|
||||
if (payload != null) {
|
||||
HashCode md5 = payload.getContentMetadata().getContentMD5AsHashCode();
|
||||
if (md5 != null) {
|
||||
String contentMD5 = BaseEncoding.base64().encode(md5.asBytes());
|
||||
requestBuilder.replaceHeader(CONTENT_MD5, contentMD5);
|
||||
signedHeadersBuilder.put(CONTENT_MD5.toLowerCase(), contentMD5);
|
||||
contentMD5 = BaseEncoding.base64().encode(md5.asBytes());
|
||||
}
|
||||
}
|
||||
if (contentMD5 != null) {
|
||||
requestBuilder.replaceHeader(CONTENT_MD5, contentMD5);
|
||||
signedHeadersBuilder.put(CONTENT_MD5.toLowerCase(), contentMD5);
|
||||
}
|
||||
|
||||
// host
|
||||
requestBuilder.replaceHeader(HttpHeaders.HOST, host);
|
||||
|
|
|
@ -127,14 +127,17 @@ public class Aws4SignerForChunkedUpload extends Aws4SignerBase {
|
|||
signedHeadersBuilder.put(CONTENT_LENGTH.toLowerCase(), Long.toString(totalLength));
|
||||
|
||||
// Content MD5
|
||||
String contentMD5 = request.getFirstHeaderOrNull(CONTENT_MD5);
|
||||
if (payload != null) {
|
||||
HashCode md5 = payload.getContentMetadata().getContentMD5AsHashCode();
|
||||
if (md5 != null) {
|
||||
String contentMD5 = BaseEncoding.base64().encode(md5.asBytes());
|
||||
requestBuilder.replaceHeader(CONTENT_MD5, contentMD5);
|
||||
signedHeadersBuilder.put(CONTENT_MD5.toLowerCase(), contentMD5);
|
||||
contentMD5 = BaseEncoding.base64().encode(md5.asBytes());
|
||||
}
|
||||
}
|
||||
if (contentMD5 != null) {
|
||||
requestBuilder.replaceHeader(CONTENT_MD5, contentMD5);
|
||||
signedHeadersBuilder.put(CONTENT_MD5.toLowerCase(), contentMD5);
|
||||
}
|
||||
|
||||
// Content Type
|
||||
// content-type is not a required signing param. However, examples use this, so we include it to ease testing.
|
||||
|
|
Loading…
Reference in New Issue