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:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 /// content-type of the request will be set to | 71 /// content-type of the request will be set to |
72 /// `"application/x-www-form-urlencoded"`; this cannot be overridden. | 72 /// `"application/x-www-form-urlencoded"`; this cannot be overridden. |
73 /// | 73 /// |
74 /// [encoding] defaults to UTF-8. | 74 /// [encoding] defaults to UTF-8. |
75 /// | 75 /// |
76 /// For more fine-grained control over the request, use [send] instead. | 76 /// For more fine-grained control over the request, use [send] instead. |
77 Future<Response> put(url, {Map<String, String> headers, body, | 77 Future<Response> put(url, {Map<String, String> headers, body, |
78 Encoding encoding}) => | 78 Encoding encoding}) => |
79 _sendUnstreamed("PUT", url, headers, body, encoding); | 79 _sendUnstreamed("PUT", url, headers, body, encoding); |
80 | 80 |
| 81 /// Sends an HTTP PATCH request with the given headers and body to the given |
| 82 /// URL, which can be a [Uri] or a [String]. |
| 83 /// |
| 84 /// [body] sets the body of the request. It can be a [String], a [List<int>] |
| 85 /// or a [Map<String, String>]. If it's a String, it's encoded using |
| 86 /// [encoding] and used as the body of the request. The content-type of the |
| 87 /// request will default to "text/plain". |
| 88 /// |
| 89 /// If [body] is a List, it's used as a list of bytes for the body of the |
| 90 /// request. |
| 91 /// |
| 92 /// If [body] is a Map, it's encoded as form fields using [encoding]. The |
| 93 /// content-type of the request will be set to |
| 94 /// `"application/x-www-form-urlencoded"`; this cannot be overridden. |
| 95 /// |
| 96 /// [encoding] defaults to UTF-8. |
| 97 /// |
| 98 /// For more fine-grained control over the request, use [send] instead. |
| 99 Future<Response> patch(url, {Map<String, String> headers, body, |
| 100 Encoding encoding}) => |
| 101 _sendUnstreamed("PATCH", url, headers, body, encoding); |
| 102 |
81 /// Sends an HTTP DELETE request with the given headers to the given URL, | 103 /// Sends an HTTP DELETE request with the given headers to the given URL, |
82 /// which can be a [Uri] or a [String]. | 104 /// which can be a [Uri] or a [String]. |
83 /// | 105 /// |
84 /// For more fine-grained control over the request, use [send] instead. | 106 /// For more fine-grained control over the request, use [send] instead. |
85 Future<Response> delete(url, {Map<String, String> headers}) => | 107 Future<Response> delete(url, {Map<String, String> headers}) => |
86 _sendUnstreamed("DELETE", url, headers); | 108 _sendUnstreamed("DELETE", url, headers); |
87 | 109 |
88 /// Sends an HTTP GET request with the given headers to the given URL, which | 110 /// Sends an HTTP GET request with the given headers to the given URL, which |
89 /// can be a [Uri] or a [String], and returns a Future that completes to the | 111 /// can be a [Uri] or a [String], and returns a Future that completes to the |
90 /// body of the response as a String. | 112 /// body of the response as a String. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 182 } |
161 if (url is String) url = Uri.parse(url); | 183 if (url is String) url = Uri.parse(url); |
162 throw new ClientException("$message.", url); | 184 throw new ClientException("$message.", url); |
163 } | 185 } |
164 | 186 |
165 /// Closes the client and cleans up any resources associated with it. It's | 187 /// Closes the client and cleans up any resources associated with it. It's |
166 /// important to close each client when it's done being used; failing to do so | 188 /// important to close each client when it's done being used; failing to do so |
167 /// can cause the Dart process to hang. | 189 /// can cause the Dart process to hang. |
168 void close() {} | 190 void close() {} |
169 } | 191 } |
OLD | NEW |