Committed by
GitHub
added send request method
enables to resend a request during an interception
Showing
1 changed file
with
13 additions
and
0 deletions
@@ -342,6 +342,19 @@ class GetHttpClient { | @@ -342,6 +342,19 @@ class GetHttpClient { | ||
342 | responseInterceptor: _responseInterceptor(responseInterceptor), | 342 | responseInterceptor: _responseInterceptor(responseInterceptor), |
343 | ); | 343 | ); |
344 | } | 344 | } |
345 | + Future<Response<T>> send<T>(Request<T> request) async { | ||
346 | + try { | ||
347 | + var response = await _performRequest<T>(() => Future.value(request)); | ||
348 | + return response; | ||
349 | + } on Exception catch (e) { | ||
350 | + if (!errorSafety) { | ||
351 | + throw GetHttpException(e.toString()); | ||
352 | + } | ||
353 | + return Future.value(Response<T>( | ||
354 | + statusText: 'Can not connect to server. Reason: $e', | ||
355 | + )); | ||
356 | + } | ||
357 | + } | ||
345 | 358 | ||
346 | Future<Response<T>> patch<T>( | 359 | Future<Response<T>> patch<T>( |
347 | String url, { | 360 | String url, { |
-
Please register or login to post a comment