@@ -10,15 +10,16 @@ import 'http_client_manager.dart';
10
10
11
11
typedef HttpResponse = http.Response ;
12
12
13
- Future <(HttpResponse ?, Duration ?, String ?)> request (
13
+ final httpClientManager = HttpClientManager ();
14
+
15
+ Future <(HttpResponse ?, Duration ?, String ?)> sendHttpRequest (
14
16
String requestId,
15
17
APIType apiType,
16
18
HttpRequestModel requestModel, {
17
19
SupportedUriSchemes defaultUriScheme = kDefaultUriScheme,
18
20
bool noSSL = false ,
19
21
}) async {
20
- final clientManager = HttpClientManager ();
21
- final client = clientManager.createClient (requestId, noSSL: noSSL);
22
+ final client = httpClientManager.createClient (requestId, noSSL: noSSL);
22
23
23
24
(Uri ? , String ? ) uriRec = getValidRequestUri (
24
25
requestModel.url,
@@ -123,14 +124,18 @@ Future<(HttpResponse?, Duration?, String?)> request(
123
124
stopwatch.stop ();
124
125
return (response, stopwatch.elapsed, null );
125
126
} catch (e) {
126
- if (clientManager .wasRequestCancelled (requestId)) {
127
+ if (httpClientManager .wasRequestCancelled (requestId)) {
127
128
return (null , null , kMsgRequestCancelled);
128
129
}
129
130
return (null , null , e.toString ());
130
131
} finally {
131
- clientManager .closeClient (requestId);
132
+ httpClientManager .closeClient (requestId);
132
133
}
133
134
} else {
134
135
return (null , null , uriRec.$2);
135
136
}
136
137
}
138
+
139
+ void cancelHttpRequest (String ? requestId) {
140
+ httpClientManager.cancelRequest (requestId);
141
+ }
0 commit comments