diff --git a/blobstore/src/main/java/org/jclouds/blobstore/functions/BlobToHttpGetOptions.java b/blobstore/src/main/java/org/jclouds/blobstore/functions/BlobToHttpGetOptions.java index a2ceb68d0e..28f3311cb8 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/functions/BlobToHttpGetOptions.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/functions/BlobToHttpGetOptions.java @@ -51,11 +51,11 @@ public class BlobToHttpGetOptions implements Function= 0, "length must be >= 0"); + getRanges().add(String.format("-%d", length)); + return this; + } + /** * Only return the object if it has changed since this time. *

diff --git a/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobToHttpGetOptionsTest.java b/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobToHttpGetOptionsTest.java index 9f3bf9dba3..ca0d8a7ddc 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobToHttpGetOptionsTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobToHttpGetOptionsTest.java @@ -103,6 +103,29 @@ public class BlobToHttpGetOptionsTest { assertEquals(fn.apply(in), expected); } + + @Test + public void testRangesTail(){ + org.jclouds.blobstore.options.GetOptions in = new org.jclouds.blobstore.options.GetOptions(); + in.tail(1024); + + GetOptions expected = new GetOptions(); + expected.tail(1024); + + assertEquals(fn.apply(in), expected); + + } + @Test + public void testRangesStart(){ + org.jclouds.blobstore.options.GetOptions in = new org.jclouds.blobstore.options.GetOptions(); + in.startAt(1024); + + GetOptions expected = new GetOptions(); + expected.startAt(1024); + + assertEquals(fn.apply(in), expected); + + } @Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class }) public void testNullIsBad() { diff --git a/blobstore/src/test/java/org/jclouds/blobstore/options/GetOptionsTest.java b/blobstore/src/test/java/org/jclouds/blobstore/options/GetOptionsTest.java index e1ab5cce68..e6eb7a611c 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/options/GetOptionsTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/options/GetOptionsTest.java @@ -136,6 +136,21 @@ public class GetOptionsTest { assertEquals(options.getRanges(), ImmutableList.of("0-5", "10-100")); } + + @Test + public void testRangeStartAt() { + GetOptions options = new GetOptions(); + options.startAt(5); + assertEquals(options.getRanges(), ImmutableList.of("5-")); + } + + @Test + public void testRangeTail() { + GetOptions options = new GetOptions(); + options.tail(5); + assertEquals(options.getRanges(), ImmutableList.of("-5")); + } + @Test public void testNoRange() { GetOptions options = new GetOptions(); diff --git a/core/src/main/java/org/jclouds/http/options/GetOptions.java b/core/src/main/java/org/jclouds/http/options/GetOptions.java index b51a66b41c..6b9564ca4a 100644 --- a/core/src/main/java/org/jclouds/http/options/GetOptions.java +++ b/core/src/main/java/org/jclouds/http/options/GetOptions.java @@ -80,7 +80,7 @@ public class GetOptions extends BaseHttpRequestOptions { */ public GetOptions startAt(long start) { checkArgument(start >= 0, "start must be >= 0"); - ranges.add(String.format("%d-%d", start, Long.MAX_VALUE)); + ranges.add(String.format("%d-", start)); return this; } diff --git a/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java b/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java index 973572531e..b76a7b8999 100644 --- a/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java +++ b/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java @@ -155,13 +155,13 @@ public class GetOptionsTest { public void testStartAt() { GetOptions options = new GetOptions(); options.startAt(100); - assertEquals(options.getRange(), "bytes=100-9223372036854775807"); + assertEquals(options.getRange(), "bytes=100-"); } @Test public void testStartAtStatic() { GetOptions options = startAt(100); - assertEquals(options.getRange(), "bytes=100-9223372036854775807"); + assertEquals(options.getRange(), "bytes=100-"); } @Test(expectedExceptions = IllegalArgumentException.class)