public static String formatRange(long... range) {
        switch (range.length) {
            case 0: return "bytes=0-";
            case 1:
                if (range[0] < 0) throw new IllegalArgumentException("negative range");
                return "bytes="+range[0]+"-";
            case 2:
                if (range[0] < 0) throw new IllegalArgumentException("negative range");
                if (range[0] > range[1]) throw new IllegalArgumentException(range[0] + ">" + range[1]);
                return "bytes="+range[0]+"-"+range[1];
            default: throw new IllegalArgumentException("invalid range specified");
        }
    }