@Test
 void testOneRange() {
   BlobToHttpGetOptions converter = new BlobToHttpGetOptions();
   org.jclouds.blobstore.options.GetOptions blobGet =
       new org.jclouds.blobstore.options.GetOptions().range(2, 5);
   GetOptions httpGet = converter.apply(blobGet);
   assertEquals(httpGet.buildRequestHeaders().get("Range"), ImmutableSet.of("bytes=2-5"));
 }
Example #2
0
 @Override
 public GetOptions apply(org.jclouds.blobstore.options.GetOptions from) {
   GetOptions httpOptions = new GetOptions();
   if (from != null && from != org.jclouds.blobstore.options.GetOptions.NONE) {
     if (from.getIfMatch() != null) {
       httpOptions.ifETagMatches(from.getIfMatch());
     }
     if (from.getIfModifiedSince() != null) {
       httpOptions.ifModifiedSince(from.getIfModifiedSince());
     }
     if (from.getIfNoneMatch() != null) {
       httpOptions.ifETagDoesntMatch(from.getIfNoneMatch());
     }
     if (from.getIfUnmodifiedSince() != null) {
       httpOptions.ifUnmodifiedSince(from.getIfUnmodifiedSince());
     }
     for (String range : from.getRanges()) {
       String[] firstLast = range.split("\\-");
       if (firstLast.length == 2)
         httpOptions.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1]));
       else if (range.startsWith("-")) httpOptions.tail(Long.parseLong(firstLast[0]));
       else httpOptions.startAt(Long.parseLong(firstLast[0]));
     }
   }
   return httpOptions;
 }