Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add request body to http request function in http library #23

Closed
DartBot opened this issue Jun 5, 2015 · 2 comments
Closed

Add request body to http request function in http library #23

DartBot opened this issue Jun 5, 2015 · 2 comments
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

Comments

@DartBot
Copy link

DartBot commented Jun 5, 2015

<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);

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/5479?v=3" align="left" width="48" height="48"hspace="10"> Comment by sethladd


Removed Type-Defect label.
Added Type-Enhancement, Area-Pkg, Pkg-Http, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


It's very rare to want to send a DELETE request with a body, and the semantics aren't very clear. The top-level methods are intended to be used for common use-cases, but there's nothing wrong with constructing an explicit Request if you're doing something out of the ordinary.


Added NotPlanned label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

1 participant