File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ class Client extends http.BaseClient {
73
73
final bool _basicAuth;
74
74
75
75
/// The underlying HTTP client.
76
- http.Client ? _httpClient;
76
+ final http.Client _httpClient;
77
77
78
78
/// Creates a new client from a pre-existing set of credentials.
79
79
///
@@ -111,7 +111,7 @@ class Client extends http.BaseClient {
111
111
}
112
112
113
113
request.headers['authorization' ] = 'Bearer ${credentials .accessToken }' ;
114
- var response = await _httpClient! .send (request);
114
+ var response = await _httpClient.send (request);
115
115
116
116
if (response.statusCode != 401 ) return response;
117
117
if (! response.headers.containsKey ('www-authenticate' )) return response;
@@ -181,7 +181,6 @@ class Client extends http.BaseClient {
181
181
/// Closes this client and its underlying HTTP client.
182
182
@override
183
183
void close () {
184
- _httpClient? .close ();
185
- _httpClient = null ;
184
+ _httpClient.close ();
186
185
}
187
186
}
Original file line number Diff line number Diff line change @@ -189,6 +189,24 @@ void main() {
189
189
190
190
expect (client.refreshCredentials (), throwsA (isStateError));
191
191
});
192
+
193
+ test ("won't send a request with closed client" , () {
194
+ var credentials = oauth2.Credentials ('access token' );
195
+
196
+ var client = oauth2.Client (
197
+ credentials,
198
+ identifier: 'identifier' ,
199
+ secret: 'secret' ,
200
+ httpClient: httpClient,
201
+ );
202
+
203
+ client.close ();
204
+
205
+ expect (
206
+ client.read (requestUri),
207
+ throwsA (const TypeMatcher <http.ClientException >()),
208
+ );
209
+ });
192
210
});
193
211
194
212
group ('with invalid credentials' , () {
You can’t perform that action at this time.
0 commit comments