File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,14 @@ Map<String, String> authHeader(Auth auth) {
51
51
class LiveApiConnection extends ApiConnection {
52
52
LiveApiConnection ({required super .auth});
53
53
54
+ final http.Client _client = http.Client ();
55
+
54
56
bool _isOpen = true ;
55
57
56
58
@override
57
59
void close () {
58
60
assert (_isOpen);
61
+ _client.close ();
59
62
_isOpen = false ;
60
63
}
61
64
@@ -73,7 +76,7 @@ class LiveApiConnection extends ApiConnection {
73
76
path: "/api/v1/$route " ,
74
77
queryParameters: encodeParameters (params));
75
78
if (kDebugMode) print ("GET $url " );
76
- final response = await http .get (url, headers: _headers ());
79
+ final response = await _client .get (url, headers: _headers ());
77
80
if (response.statusCode != 200 ) {
78
81
throw Exception ("error on GET $route : status ${response .statusCode }" );
79
82
}
@@ -83,7 +86,7 @@ class LiveApiConnection extends ApiConnection {
83
86
@override
84
87
Future <String > post (String route, Map <String , dynamic >? params) async {
85
88
assert (_isOpen);
86
- final response = await http .post (
89
+ final response = await _client .post (
87
90
Uri .parse ("${auth .realmUrl }/api/v1/$route " ),
88
91
headers: _headers (),
89
92
body: encodeParameters (params));
You can’t perform that action at this time.
0 commit comments