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 library base_client; | 5 library base_client; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:scalarlist'; | 8 import 'dart:scalarlist'; |
9 import 'dart:uri'; | 9 import 'dart:uri'; |
10 | 10 |
11 import 'base_request.dart'; | 11 import 'base_request.dart'; |
| 12 import 'client.dart'; |
12 import 'request.dart'; | 13 import 'request.dart'; |
13 import 'response.dart'; | 14 import 'response.dart'; |
14 import 'streamed_response.dart'; | 15 import 'streamed_response.dart'; |
15 import 'utils.dart'; | 16 import 'utils.dart'; |
16 | 17 |
17 /// The abstract base class for an HTTP client. This is a mixin-style class; | 18 /// The abstract base class for an HTTP client. This is a mixin-style class; |
18 /// subclasses only need to implement [send] and maybe [close], and then they | 19 /// subclasses only need to implement [send] and maybe [close], and then they |
19 /// get various convenience methods for free. | 20 /// get various convenience methods for free. |
20 abstract class BaseClient { | 21 abstract class BaseClient implements Client { |
21 /// Sends an HTTP HEAD request with the given headers to the given URL, which | 22 /// Sends an HTTP HEAD request with the given headers to the given URL, which |
22 /// can be a [Uri] or a [String]. | 23 /// can be a [Uri] or a [String]. |
23 /// | 24 /// |
24 /// For more fine-grained control over the request, use [send] instead. | 25 /// For more fine-grained control over the request, use [send] instead. |
25 Future<Response> head(url, {Map<String, String> headers}) => | 26 Future<Response> head(url, {Map<String, String> headers}) => |
26 _sendUnstreamed("HEAD", url, headers); | 27 _sendUnstreamed("HEAD", url, headers); |
27 | 28 |
28 /// Sends an HTTP GET request with the given headers to the given URL, which | 29 /// Sends an HTTP GET request with the given headers to the given URL, which |
29 /// can be a [Uri] or a [String]. | 30 /// can be a [Uri] or a [String]. |
30 /// | 31 /// |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 message = "$message: ${response.reasonPhrase}"; | 127 message = "$message: ${response.reasonPhrase}"; |
127 } | 128 } |
128 throw new HttpException("$message."); | 129 throw new HttpException("$message."); |
129 } | 130 } |
130 | 131 |
131 /// Closes the client and cleans up any resources associated with it. It's | 132 /// Closes the client and cleans up any resources associated with it. It's |
132 /// important to close each client when it's done being used; failing to do so | 133 /// important to close each client when it's done being used; failing to do so |
133 /// can cause the Dart process to hang. | 134 /// can cause the Dart process to hang. |
134 void close() {} | 135 void close() {} |
135 } | 136 } |
OLD | NEW |