send static method
Future<StreamedResponse?>
send(
- BaseRequest request, {
- CancellationToken? cancelToken,
- int retries = 3,
- Duration? timeLimit,
- Duration timeRetry = const Duration(milliseconds: 100),
- 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,
);
}