mirror of https://github.com/apache/jclouds.git
Add Atmos-specific MD5 checksum header
Tested that Atmos Online and Synaptic Atmos both enforce this.
This commit is contained in:
parent
0d310f3643
commit
98230e60a4
|
@ -22,7 +22,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import com.google.common.io.BaseEncoding;
|
||||
|
||||
import org.jclouds.atmos.domain.AtmosObject;
|
||||
import org.jclouds.atmos.reference.AtmosHeaders;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
|
||||
|
@ -47,6 +50,15 @@ public class BindMetadataToHeaders implements Binder {
|
|||
checkNotNull(object.getPayload(), "object payload");
|
||||
checkArgument(object.getPayload().getContentMetadata().getContentLength() != null,
|
||||
"contentLength must be set, streaming not supported");
|
||||
byte[] contentMD5 = object.getContentMetadata().getContentMD5();
|
||||
if (contentMD5 != null) {
|
||||
// Swizzle Content-MD5 to Atmos-specific header
|
||||
object.getContentMetadata().setContentMD5(null);
|
||||
request = (R) request.toBuilder()
|
||||
.addHeader(AtmosHeaders.CHECKSUM, "MD5/0/" +
|
||||
BaseEncoding.base64().encode(contentMD5))
|
||||
.build();
|
||||
}
|
||||
return metaBinder.bindToRequest(request, object.getUserMetadata());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,5 +35,6 @@ public interface AtmosHeaders {
|
|||
public static final String GROUP_ACL = "x-emc-groupacl";
|
||||
public static final String UID = "x-emc-uid";
|
||||
public static final String TOKEN = "x-emc-token";
|
||||
public static final String CHECKSUM = "x-emc-wschecksum";
|
||||
|
||||
}
|
||||
|
|
|
@ -99,7 +99,12 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest<AtmosAsyncCl
|
|||
"POST https://accesspoint.atmosonline.com/rest/namespace/container/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(
|
||||
request,
|
||||
"Accept: */*\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nExpect: 100-continue\nx-emc-signature: 7Cbdnu+YA5rG9J/C9RlHk07mU7w=\nx-emc-uid: identity\n");
|
||||
"Accept: */*\n" +
|
||||
"Date: Thu, 05 Jun 2008 16:38:19 GMT\n" +
|
||||
"Expect: 100-continue\n" +
|
||||
"x-emc-signature: PY3MQyILhoLDVoKfnB6ECTRaCWQ=\n" +
|
||||
"x-emc-uid: identity\n" +
|
||||
"x-emc-wschecksum: MD5/0/AAIECA==\n");
|
||||
|
||||
assertContentHeadersEqual(request, "text/plain", null, null, null, 2L, new byte[] { 0, 2, 4, 8 }, new Date(1000));
|
||||
|
||||
|
|
Loading…
Reference in New Issue