send static method

Future<StreamedResponse?> send(
  1. BaseRequest request, {
  2. CancellationToken? cancelToken,
  3. int retries = 3,
  4. Duration? timeLimit,
  5. Duration timeRetry = const Duration(milliseconds: 100),
  6. FutureOr<StreamedResponse> onTimeout()?,
})

Implementation

static Future<StreamedResponse?> send(
  BaseRequest request, {
  CancellationToken? cancelToken,
  int retries = 3,
  Duration? timeLimit,
  Duration timeRetry = const Duration(milliseconds: 100),
  FutureOr<StreamedResponse> Function()? onTimeout,
}) async {
  cancelToken?.throwIfCancellationRequested();
  return await RetryHelper.tryRun<StreamedResponse>(
    () {
      return CancellationTokenSource.register(
        cancelToken,
        timeLimit == null
            ? _httpClient.send(request)
            : _httpClient.send(request).timeout(
                  timeLimit,
                  onTimeout: onTimeout,
                ),
      );
    },
    cancelToken: cancelToken,
    timeRetry: timeRetry,
    retries: retries,
  );
}