Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: lib/http.dart

Issue 1922883004: Fix more strong-mode warnings. (Closed) Base URL: git@github.com:dart-lang/http@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/multipart_file.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/http.dart
diff --git a/lib/http.dart b/lib/http.dart
index 497e447b739c79933d44b3eaca22071445583f36..9ccd77a6f892f2785133c33b0ee0f25cb08c5a6f 100644
--- a/lib/http.dart
+++ b/lib/http.dart
@@ -161,8 +161,11 @@ Future<String> read(url, {Map<String, String> headers}) =>
Future<Uint8List> readBytes(url, {Map<String, String> headers}) =>
_withClient((client) => client.readBytes(url, headers: headers));
-Future _withClient(Future fn(Client)) {
+Future/*<T>*/ _withClient/*<T>*/(Future/*<T>*/ fn(Client client)) async {
var client = new Client();
- var future = fn(client);
- return future.whenComplete(client.close);
+ try {
+ return await fn(client);
+ } finally {
+ client.close();
+ }
}
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/multipart_file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698