open static method
Opens url, learning its size from the Content-Range of a one-byte
request. Throws a TiffException if the server doesn't support Range
requests or doesn't expose Content-Range.
Implementation
static Future<HttpRangeByteSource> open(
Uri url, {
Map<String, String> headers = const {},
}) async {
final response = await _get(url, headers, 0, 0);
final contentRange = response.headers.get('Content-Range');
final total = contentRange == null
? null
: int.tryParse(
contentRange.substring(contentRange.lastIndexOf('/') + 1),
);
if (total == null) {
throw TiffException(
'$url: no usable Content-Range header in the response (got '
'"$contentRange"); cross-origin, the server must send '
'"Access-Control-Expose-Headers: Content-Range"',
);
}
return HttpRangeByteSource._(url, headers, total);
}