我正在试图理解DART:IO库中http package和HttpClient class之间的区别.我的目的是知道我什么时候应该用哪一种.我看到他们两个人显然都做过同样的事情.
我认为这些问答是这样的:
- Choosing between package:html, dart:html, dart:io (class HttpClient) and package:http APIs to fetch HTTP resources
- How to make HTTPS request using HttpClient in dart?个
- In a Dart console application, is there a library for an HTTP Request that doesnt require DOM access?个
- How to do POST in Dart command line HttpClient个
这是我到目前为止认为是正确的,但我的理解是模糊的:
-
http
表示高级别,HttpClient
表示低级别(source) -
http
可以发出POST请求,但HttpClient
不能(source) -
http
和HttpClient
(具有HttpClientRequest
)都可以发出GET和POST请求(source) -
http
和HttpClient
都可以在客户端和服务器上使用
所以总而言之,我想说每个都可以做任何其他人也能做的事情,但使用http
包更容易,因为这个包更多的是high-level.这个总结正确吗?