Add optional body to delete (#439)
The spec discourages but does not forbid a body. Allow a body argument
without falling back on the `send` API since some servers may be
designed specifically to require it.
Closes #383, closes #206
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 353b11b..e08586b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@
* Add `const` constructor to `ByteStream`.
* Migrate `BrowserClient` from `blob` to `arraybuffer`.
+* **Breaking** Added a `body` and `encoding` argument to `Client.delete`. This
+ is only breaking for implementations which override that method.
## 0.12.2
diff --git a/lib/http.dart b/lib/http.dart
index 0976043..7b42071 100644
--- a/lib/http.dart
+++ b/lib/http.dart
@@ -127,8 +127,10 @@
/// the same server, you should use a single [Client] for all of those requests.
///
/// For more fine-grained control over the request, use [Request] instead.
-Future<Response> delete(Object url, {Map<String, String>? headers}) =>
- _withClient((client) => client.delete(url, headers: headers));
+Future<Response> delete(Object url,
+ {Map<String, String>? headers, Object? body, Encoding? encoding}) =>
+ _withClient((client) =>
+ client.delete(url, headers: headers, body: body, encoding: encoding));
/// Sends an HTTP GET request with the given headers to the given URL, which can
/// be a [Uri] or a [String], and returns a Future that completes to the body of
diff --git a/lib/src/base_client.dart b/lib/src/base_client.dart
index db70215..52eae4b 100644
--- a/lib/src/base_client.dart
+++ b/lib/src/base_client.dart
@@ -42,8 +42,9 @@
_sendUnstreamed('PATCH', url, headers, body, encoding);
@override
- Future<Response> delete(Object url, {Map<String, String>? headers}) =>
- _sendUnstreamed('DELETE', url, headers);
+ Future<Response> delete(Object url,
+ {Map<String, String>? headers, Object? body, Encoding? encoding}) =>
+ _sendUnstreamed('DELETE', url, headers, body, encoding);
@override
Future<String> read(Object url, {Map<String, String>? headers}) async {
diff --git a/lib/src/client.dart b/lib/src/client.dart
index d289699..19c2a88 100644
--- a/lib/src/client.dart
+++ b/lib/src/client.dart
@@ -110,7 +110,8 @@
/// which can be a [Uri] or a [String].
///
/// For more fine-grained control over the request, use [send] instead.
- Future<Response> delete(Object url, {Map<String, String>? headers});
+ Future<Response> delete(Object url,
+ {Map<String, String>? headers, Object? body, Encoding? encoding});
/// Sends an HTTP GET request with the given headers to the given URL, which
/// can be a [Uri] or a [String], and returns a Future that completes to the