regression, added default content type for rackspace

This commit is contained in:
Adrian Cole 2010-07-08 04:09:31 -07:00
parent da3baf523c
commit ef496e7262
2 changed files with 11 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.ws.rs.core.MediaType;
import org.jclouds.blobstore.binders.BindUserMetadataToHeadersWithPrefix; import org.jclouds.blobstore.binders.BindUserMetadataToHeadersWithPrefix;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
@ -44,6 +45,8 @@ public class BindCFObjectToPayload implements Binder {
public void bindToRequest(HttpRequest request, Object payload) { public void bindToRequest(HttpRequest request, Object payload) {
CFObject object = (CFObject) payload; CFObject object = (CFObject) payload;
if (object.getPayload().getContentType() == null)
object.getPayload().setContentType(MediaType.APPLICATION_OCTET_STREAM);
if (object.getPayload().getContentLength() != null if (object.getPayload().getContentLength() != null
&& object.getPayload().getContentLength() >= 0) { && object.getPayload().getContentLength() >= 0) {
checkArgument(object.getPayload().getContentLength() <= 5l * 1024 * 1024 * 1024, checkArgument(object.getPayload().getContentLength() <= 5l * 1024 * 1024 * 1024,

View File

@ -23,6 +23,8 @@ import static org.easymock.classextension.EasyMock.createMock;
import static org.easymock.classextension.EasyMock.replay; import static org.easymock.classextension.EasyMock.replay;
import static org.easymock.classextension.EasyMock.verify; import static org.easymock.classextension.EasyMock.verify;
import javax.ws.rs.core.MediaType;
import org.jclouds.blobstore.binders.BindUserMetadataToHeadersWithPrefix; import org.jclouds.blobstore.binders.BindUserMetadataToHeadersWithPrefix;
import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
@ -53,6 +55,8 @@ public class BindCFObjectToPayloadTest {
MutableObjectInfoWithMetadata md = createMock(MutableObjectInfoWithMetadata.class); MutableObjectInfoWithMetadata md = createMock(MutableObjectInfoWithMetadata.class);
expect(object.getPayload()).andReturn(payload).atLeastOnce(); expect(object.getPayload()).andReturn(payload).atLeastOnce();
expect(payload.getContentType()).andReturn(null).atLeastOnce();
payload.setContentType(MediaType.APPLICATION_OCTET_STREAM);
expect(payload.getContentLength()).andReturn(5368709120l).atLeastOnce(); expect(payload.getContentLength()).andReturn(5368709120l).atLeastOnce();
expect(object2Blob.apply(object)).andReturn(blob); expect(object2Blob.apply(object)).andReturn(blob);
mdBinder.bindToRequest(request, blob); mdBinder.bindToRequest(request, blob);
@ -93,6 +97,8 @@ public class BindCFObjectToPayloadTest {
Multimap<String, String> headers = createMock(Multimap.class); Multimap<String, String> headers = createMock(Multimap.class);
expect(object.getPayload()).andReturn(payload).atLeastOnce(); expect(object.getPayload()).andReturn(payload).atLeastOnce();
expect(payload.getContentType()).andReturn(null).atLeastOnce();
payload.setContentType(MediaType.APPLICATION_OCTET_STREAM);
expect(payload.getContentLength()).andReturn(null).atLeastOnce(); expect(payload.getContentLength()).andReturn(null).atLeastOnce();
expect(object2Blob.apply(object)).andReturn(blob); expect(object2Blob.apply(object)).andReturn(blob);
mdBinder.bindToRequest(request, blob); mdBinder.bindToRequest(request, blob);
@ -135,6 +141,8 @@ public class BindCFObjectToPayloadTest {
MutableObjectInfoWithMetadata md = createMock(MutableObjectInfoWithMetadata.class); MutableObjectInfoWithMetadata md = createMock(MutableObjectInfoWithMetadata.class);
expect(object.getPayload()).andReturn(payload).atLeastOnce(); expect(object.getPayload()).andReturn(payload).atLeastOnce();
expect(payload.getContentType()).andReturn(null).atLeastOnce();
payload.setContentType(MediaType.APPLICATION_OCTET_STREAM);
expect(payload.getContentLength()).andReturn(5368709121l).atLeastOnce(); expect(payload.getContentLength()).andReturn(5368709121l).atLeastOnce();
expect(object2Blob.apply(object)).andReturn(blob); expect(object2Blob.apply(object)).andReturn(blob);
mdBinder.bindToRequest(request, blob); mdBinder.bindToRequest(request, blob);