mirror of
https://github.com/apache/jclouds.git
synced 2025-03-08 09:49:40 +00:00
Test for Content-Range header in single range get
Also emit this header in LocalBlobStore.
This commit is contained in:
parent
1f7f8c8c86
commit
3a410a25a8
@ -95,6 +95,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.net.HttpHeaders;
|
||||
|
||||
@Singleton
|
||||
public final class LocalBlobStore implements BlobStore {
|
||||
@ -653,6 +654,8 @@ public final class LocalBlobStore implements BlobStore {
|
||||
last = data.length - 1;
|
||||
}
|
||||
out.write(data, offset, last - offset + 1);
|
||||
blob.getAllHeaders().put(HttpHeaders.CONTENT_RANGE,
|
||||
offset + "-" + last + "/" + data.length);
|
||||
}
|
||||
ContentMetadata cmd = blob.getPayload().getContentMetadata();
|
||||
byte[] byteArray = out.toByteArray();
|
||||
|
@ -93,6 +93,7 @@ import com.google.common.hash.HashCode;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.net.HttpHeaders;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||
@ -396,10 +397,12 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||
Blob blob1 = view.getBlobStore().getBlob(container, name, range(0, 5));
|
||||
validateMetadata(blob1.getMetadata(), container, name);
|
||||
assertEquals(getContentAsStringOrNullAndClose(blob1), TEST_STRING.substring(0, 6));
|
||||
assertThat(blob1.getAllHeaders().get(HttpHeaders.CONTENT_RANGE)).containsExactly("0-5/46");
|
||||
|
||||
Blob blob2 = view.getBlobStore().getBlob(container, name, range(6, TEST_STRING.length()));
|
||||
validateMetadata(blob2.getMetadata(), container, name);
|
||||
assertEquals(getContentAsStringOrNullAndClose(blob2), TEST_STRING.substring(6, TEST_STRING.length()));
|
||||
assertThat(blob2.getAllHeaders().get(HttpHeaders.CONTENT_RANGE)).containsExactly("6-45/46");
|
||||
|
||||
/* RFC 2616 14.35.1
|
||||
"If the entity is shorter than the specified suffix-length, the
|
||||
@ -407,6 +410,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||
Blob blob3 = view.getBlobStore().getBlob(container, name, new GetOptions().tail(TEST_STRING.length() + 10));
|
||||
validateMetadata(blob3.getMetadata(), container, name);
|
||||
assertEquals(getContentAsStringOrNullAndClose(blob3), TEST_STRING);
|
||||
assertThat(blob3.getAllHeaders().get(HttpHeaders.CONTENT_RANGE)).containsExactly("0-45/46");
|
||||
} finally {
|
||||
returnContainer(container);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user