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

Side by Side 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, 7 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 unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/multipart_file.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// A composable, [Future]-based library for making HTTP requests. 5 /// A composable, [Future]-based library for making HTTP requests.
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:convert'; 7 import 'dart:convert';
8 import 'dart:typed_data'; 8 import 'dart:typed_data';
9 9
10 import 'src/client.dart'; 10 import 'src/client.dart';
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 /// 154 ///
155 /// This automatically initializes a new [Client] and closes that client once 155 /// This automatically initializes a new [Client] and closes that client once
156 /// the request is complete. If you're planning on making multiple requests to 156 /// the request is complete. If you're planning on making multiple requests to
157 /// the same server, you should use a single [Client] for all of those requests. 157 /// the same server, you should use a single [Client] for all of those requests.
158 /// 158 ///
159 /// For more fine-grained control over the request and response, use [Request] 159 /// For more fine-grained control over the request and response, use [Request]
160 /// instead. 160 /// instead.
161 Future<Uint8List> readBytes(url, {Map<String, String> headers}) => 161 Future<Uint8List> readBytes(url, {Map<String, String> headers}) =>
162 _withClient((client) => client.readBytes(url, headers: headers)); 162 _withClient((client) => client.readBytes(url, headers: headers));
163 163
164 Future _withClient(Future fn(Client)) { 164 Future/*<T>*/ _withClient/*<T>*/(Future/*<T>*/ fn(Client client)) async {
165 var client = new Client(); 165 var client = new Client();
166 var future = fn(client); 166 try {
167 return future.whenComplete(client.close); 167 return await fn(client);
168 } finally {
169 client.close();
170 }
168 } 171 }
OLDNEW
« 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