File tree Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 1+ ## 2.0.5
2+
3+ * Make underlying HTTP client non-nullable to inherit its close behavior.
4+
15## 2.0.4
26
37* Updated README with example for Flutter Web.
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ class Client extends http.BaseClient {
7373 final bool _basicAuth;
7474
7575 /// The underlying HTTP client.
76- http.Client ? _httpClient;
76+ final http.Client _httpClient;
7777
7878 /// Creates a new client from a pre-existing set of credentials.
7979 ///
@@ -111,7 +111,7 @@ class Client extends http.BaseClient {
111111 }
112112
113113 request.headers['authorization' ] = 'Bearer ${credentials .accessToken }' ;
114- var response = await _httpClient! .send (request);
114+ var response = await _httpClient.send (request);
115115
116116 if (response.statusCode != 401 ) return response;
117117 if (! response.headers.containsKey ('www-authenticate' )) return response;
@@ -181,7 +181,6 @@ class Client extends http.BaseClient {
181181 /// Closes this client and its underlying HTTP client.
182182 @override
183183 void close () {
184- _httpClient? .close ();
185- _httpClient = null ;
184+ _httpClient.close ();
186185 }
187186}
Original file line number Diff line number Diff line change 11name : oauth2
2- version : 2.0.4
2+ version : 2.0.5
33description : >-
44 A client library for authenticating with a remote service via OAuth2 on
55 behalf of a user, and making authorized HTTP requests with the user's
Original file line number Diff line number Diff line change @@ -189,6 +189,24 @@ void main() {
189189
190190 expect (client.refreshCredentials (), throwsA (isStateError));
191191 });
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+ });
192210 });
193211
194212 group ('with invalid credentials' , () {
You can’t perform that action at this time.
0 commit comments