read static method

Future<String?> read(
  1. Uri url, {
  2. Map<String, String>? headers,
  3. CancellationToken? cancelToken,
  4. int retries = 3,
  5. Duration? timeLimit,
  6. Duration timeRetry = const Duration(milliseconds: 100),
  7. FutureOr<String> onTimeout()?,
})

Implementation

static Future<String?> read(
  Uri url, {
  Map<String, String>? headers,
  CancellationToken? cancelToken,
  int retries = 3,
  Duration? timeLimit,
  Duration timeRetry = const Duration(milliseconds: 100),
  FutureOr<String> Function()? onTimeout,
}) async {
  cancelToken?.throwIfCancellationRequested();
  return await RetryHelper.tryRun<String>(
    () {
      return CancellationTokenSource.register(
        cancelToken,
        timeLimit == null
            ? _httpClient.read(
                url,
                headers: headers,
              )
            : _httpClient
                .read(
                  url,
                  headers: headers,
                )
                .timeout(
                  timeLimit,
                  onTimeout: onTimeout,
                ),
      );
    },
    cancelToken: cancelToken,
    timeRetry: timeRetry,
    retries: retries,
  );
}