Add request body to http request function in http library #23
Labels
closed-not-planned
Closed as we don't intend to take action on the reported issue
type-enhancement
A request for a change that isn't a bug
<img src="https://avatars.githubusercontent.com/u/1688987?v=3" align="left" width="96" height="96"hspace="10"> Issue by luisvt
Originally opened as dart-lang/sdk#20839
Add the ability to send http request body to delete function on http library (https://pub.dartlang.org/packages/http).
I was trying to use next code:
delete('http://127.0.0.1:4040/persons', body: '[1,2]').then((Response response) {
//... other code ...
});
I realize that it wasn't possible to do it since the function doesn't support a request body. So instead, I should use next code:
new Client().send(new Request('DELETE', new Uri.http('127.0.0.1:4040', '/persons'))..body = '[1,2]').then((response) {
//... other code ...
});
Although is not a big problem on doing in the second way all the time, it would be great to be able on doing in the first way.
I know that you should modify lines 107 and 108 on file http from this:
Future<Uint8List> delete(url, {Map<String, String> headers}) =>
_withClient((client) => client.delete(url, headers: headers));
to this:
Future<Uint8List> delete(url, {Map<String, String> headers, body}) =>
_withClient((client) => client.delete(url, headers: headers, body));
also line 96 on client.dart from this:
Future<Response> delete(url, {Map<String, String> headers});
to this:
Future<Response> delete(url, {Map<String, String> headers, body});
and also lines 85 and 86 in base_client.dart from this:
Future<Response> delete(url, {Map<String, String> headers}) =>
_sendUnstreamed("DELETE", url, headers);
to this:
Future<Response> delete(url, {Map<String, String> headers, body}) =>
_sendUnstreamed("DELETE", url, headers, body);
The text was updated successfully, but these errors were encountered: