agent.createConnection(options[, callback])
options<Object> 包含连接详细信息的选项。 查看net.createConnection()以获取选项的格式callback<Function> 接收创建的套接字的回调函数- 返回: <stream.Duplex>
生成用于 HTTP 请求的套接字/流。
默认情况下,此函数与 net.createConnection() 相同。
但是,如果需要更大的灵活性,自定义代理可能会覆盖此方法。
可以通过以下两种方式之一提供套接字/流:通过从此函数返回套接字/流,或将套接字/流传给 callback。
此方法保证返回 <net.Socket> 类(<stream.Duplex> 的子类)的实例,除非用户指定 <net.Socket> 以外的套接字类型。
callback 的参数为 (err, stream)。
options<Object> Options containing connection details. Checknet.createConnection()for the format of the optionscallback<Function> Callback function that receives the created socket- Returns: <stream.Duplex>
Produces a socket/stream to be used for HTTP requests.
By default, this function is the same as net.createConnection(). However,
custom agents may override this method in case greater flexibility is desired.
A socket/stream can be supplied in one of two ways: by returning the
socket/stream from this function, or by passing the socket/stream to callback.
This method is guaranteed to return an instance of the <net.Socket> class, a subclass of <stream.Duplex>, unless the user specifies a socket type other than <net.Socket>.
callback has a signature of (err, stream).