net
进程:
net
模块是一个发送 HTTP(S) 请求的客户端API。 它类似于Node.js的HTTP 和 模块 ,但它使用的是Chromium原生网络库来替代Node.js的实现,提供更好的网络代理支持。 它还支持检查网络状态。
下面是一个非详尽的列表, 用于说明为什么使用 net
模块而不是原生Node. js 模块:
- HTTPS 请求的自动隧道。
- 支持使用basic、digest、NTLM、Kerberos 或协商身份验证方案对代理进行身份验证。
Example usage:
The net
API can be used only after the application emits the ready
event. Trying to use the module before the ready
event will throw an error.
模块具有以下方法:
options
(ClientRequestConstructorOptions | String) - TheClientRequest
constructor options.
使用 options
创建 ClientRequest
实例, 这些选项直接转发到 ClientRequest
的构造函数。 方法将根据 options
对象中的指定协议方案, 去发送安全和不安全的 HTTP 请求( both secure and insecure HTTP requests)。
Returns Boolean
- Whether there is currently internet connection.
A return value of false
is a pretty strong indicator that the user won’t be able to connect to remote sites. However, a return value of true
is inconclusive; even if some link is up, it is uncertain whether a particular connection attempt to a particular remote site will be successful.
Properties
A return value of is a pretty strong indicator that the user won’t be able to connect to remote sites. However, a return value of true
is inconclusive; even if some link is up, it is uncertain whether a particular connection attempt to a particular remote site will be successful.