fetchStream method

  1. @override
Future<HttpContent> fetchStream(
  1. Uri reference
)
override

Fetch content as a stream from a resource identified by reference.

Depending on the API the reference can be a relative path, an absolute URL, a key, or other identifier relevant on a context of an API.

Throws an ApiException if fetching fails. Implementations like HTTP fetcher may also throw other status codes than codes for success as exceptions.

Implementation

@override
Future<HttpContent> fetchStream(Uri reference) async {
  // resolve uri
  final uri = _resolver(reference);

  // do GET request and receive a streaming HTTP response
  final http.StreamedResponse response;
  try {
    response = await _adapter.getStreamed(uri, headers: _baseHeaders);
  } on Exception catch (e) {
    throw ClientException.failed(reference, e);
  }

  // form content instance  from response (and original uri reference)
  return _validator(reference, response);
}