How can DELETE requests be made with a Dart HttpClient?

戏子无情 提交于 2019-12-04 05:25:42

问题


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?


回答1:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!