If you're using a Dart HttpClient
(which provides an HttpClientRequest
) to make requests from a server to another server, as far as I can tell the only HTTP methods available are GET
and POST
(corresponding, respectively, to the post
/postUrl
and get
/getUrl
functions). Is there also a way to make PUT
and DELETE
requests?
You should be able to do with this with the open method which allows you to use any HTTP verb:
client.open('delete', 'http://example.com', '8080', '/test');
If you look at the HttpClient source you'll see that the get
and post
methods are just aliases for open
anyway:
Future<HttpClientRequest> post(String host,
int port,
String path) {
return open("post", host, port, path);
}
来源:https://stackoverflow.com/questions/22460194/how-can-delete-requests-be-made-with-a-dart-httpclient