added test for range requests with filesystem backend and corrected behavior

This commit is contained in:
Sebastian Annies 2011-08-12 13:48:32 +02:00
parent 5843d5fee9
commit 173592f7d5
3 changed files with 752 additions and 726 deletions

View File

@ -567,7 +567,7 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore {
String[] firstLast = s.split("\\-");
int offset = Integer.parseInt(firstLast[0]);
int last = Integer.parseInt(firstLast[1]);
int length = (last < data.length) ? last + 1 : data.length - offset;
int length = last - offset + 1; // the range end is included
out.write(data, offset, length);
} else {
return immediateFailedFuture(new IllegalArgumentException("first and last were null!"));

View File

@ -55,6 +55,9 @@ public class GetOptions {
/**
* download the specified range of the object.
* @param start first offset included in the response
* @param end last offset included in the response (inclusive).
* @return itself to enable daisy-chaining of expressions
*/
public GetOptions range(long start, long end) {
checkArgument(start >= 0, "start must be >= 0");