| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /// | 6 /// |
| 7 /// The easiest way to use this library is via the top-level functions. They | 7 /// The easiest way to use this library is via the top-level functions. They |
| 8 /// allow you to make individual HTTP requests with minimal hassle: | 8 /// allow you to make individual HTTP requests with minimal hassle: |
| 9 /// | 9 /// |
| 10 /// import 'package:http/http.dart' as http; | 10 /// import 'package:http/http.dart' as http; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 import 'dart:scalarlist'; | 59 import 'dart:scalarlist'; |
| 60 import 'dart:uri'; | 60 import 'dart:uri'; |
| 61 | 61 |
| 62 import 'src/client.dart'; | 62 import 'src/client.dart'; |
| 63 import 'src/response.dart'; | 63 import 'src/response.dart'; |
| 64 | 64 |
| 65 export 'src/base_client.dart'; | 65 export 'src/base_client.dart'; |
| 66 export 'src/base_request.dart'; | 66 export 'src/base_request.dart'; |
| 67 export 'src/base_response.dart'; | 67 export 'src/base_response.dart'; |
| 68 export 'src/client.dart'; | 68 export 'src/client.dart'; |
| 69 export 'src/multipart_file.dart'; |
| 70 export 'src/multipart_request.dart'; |
| 69 export 'src/request.dart'; | 71 export 'src/request.dart'; |
| 70 export 'src/response.dart'; | 72 export 'src/response.dart'; |
| 71 export 'src/streamed_request.dart'; | 73 export 'src/streamed_request.dart'; |
| 72 export 'src/streamed_response.dart'; | 74 export 'src/streamed_response.dart'; |
| 73 | 75 |
| 74 /// Sends an HTTP HEAD request with the given headers to the given URL, which | 76 /// Sends an HTTP HEAD request with the given headers to the given URL, which |
| 75 /// can be a [Uri] or a [String]. | 77 /// can be a [Uri] or a [String]. |
| 76 /// | 78 /// |
| 77 /// This automatically initializes a new [Client] and closes that client once | 79 /// This automatically initializes a new [Client] and closes that client once |
| 78 /// the request is complete. If you're planning on making multiple requests to | 80 /// the request is complete. If you're planning on making multiple requests to |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 /// instead. | 167 /// instead. |
| 166 Future<Uint8List> readBytes(url, {Map<String, String> headers}) => | 168 Future<Uint8List> readBytes(url, {Map<String, String> headers}) => |
| 167 _withClient((client) => client.readBytes(url, headers: headers)); | 169 _withClient((client) => client.readBytes(url, headers: headers)); |
| 168 | 170 |
| 169 Future _withClient(Future fn(Client)) { | 171 Future _withClient(Future fn(Client)) { |
| 170 var client = new Client(); | 172 var client = new Client(); |
| 171 var future = fn(client); | 173 var future = fn(client); |
| 172 future.onComplete((_) => client.close()); | 174 future.onComplete((_) => client.close()); |
| 173 return future; | 175 return future; |
| 174 } | 176 } |
| OLD | NEW |