如何使用Dart HttpClient进行DELETE请求? [英] How can DELETE requests be made with a Dart HttpClient?

查看:308
本文介绍了如何使用Dart HttpClient进行DELETE请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您使用Dart HttpClient (提供 HttpClientRequest )从服务器发出请求另一个服务器,只要我能告诉只有HTTP方法可用的是 GET POST post / postUrl get / getUrl 函数)。是否还有一种方法使 PUT DELETE 请求?

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?

推荐答案

您应该可以使用打开方法,它允许您使用任何HTTP动词:

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

如果您查看 HttpClient来源,您会看到 get post 方法只是打开的别名:

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

这篇关于如何使用Dart HttpClient进行DELETE请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆