code: public static Long calculateRangeLength(FileRequestContext context, Range range) {
      if(range.start == -1) range.start = 0;
      if(range.end == -1) range.end = context.file.length() - 1;
      range.length = range.end - range.start + 1;
      return range.length;
    }
docs: Calculates the length of a given range.
  
  @param context
  @param range
  @return