Skip to content

Commit 3845753

Browse files
author
Julian
authored
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
1 parent d473635 commit 3845753

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ null safety allow list.
1111

1212
* Add `const` constructor to `ByteStream`.
1313
* Migrate `BrowserClient` from `blob` to `arraybuffer`.
14+
* **Breaking** Added a `body` and `encoding` argument to `Client.delete`. This
15+
is only breaking for implementations which override that method.
1416

1517
## 0.12.2
1618

lib/http.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ Future<Response> patch(Object url,
127127
/// the same server, you should use a single [Client] for all of those requests.
128128
///
129129
/// For more fine-grained control over the request, use [Request] instead.
130-
Future<Response> delete(Object url, {Map<String, String>? headers}) =>
131-
_withClient((client) => client.delete(url, headers: headers));
130+
Future<Response> delete(Object url,
131+
{Map<String, String>? headers, Object? body, Encoding? encoding}) =>
132+
_withClient((client) =>
133+
client.delete(url, headers: headers, body: body, encoding: encoding));
132134

133135
/// Sends an HTTP GET request with the given headers to the given URL, which can
134136
/// be a [Uri] or a [String], and returns a Future that completes to the body of

lib/src/base_client.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ abstract class BaseClient implements Client {
4242
_sendUnstreamed('PATCH', url, headers, body, encoding);
4343

4444
@override
45-
Future<Response> delete(Object url, {Map<String, String>? headers}) =>
46-
_sendUnstreamed('DELETE', url, headers);
45+
Future<Response> delete(Object url,
46+
{Map<String, String>? headers, Object? body, Encoding? encoding}) =>
47+
_sendUnstreamed('DELETE', url, headers, body, encoding);
4748

4849
@override
4950
Future<String> read(Object url, {Map<String, String>? headers}) async {

lib/src/client.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ abstract class Client {
110110
/// which can be a [Uri] or a [String].
111111
///
112112
/// For more fine-grained control over the request, use [send] instead.
113-
Future<Response> delete(Object url, {Map<String, String>? headers});
113+
Future<Response> delete(Object url,
114+
{Map<String, String>? headers, Object? body, Encoding? encoding});
114115

115116
/// Sends an HTTP GET request with the given headers to the given URL, which
116117
/// can be a [Uri] or a [String], and returns a Future that completes to the

0 commit comments

Comments
 (0)