当http.request有2个事件产生错误时:request.on('error')和response.on('error').
我看不出有什么不同,因为这两个错误都来自Web服务器.
thisError和之间有什么区别thatError?
var request = http.request({hostname:"example.com"}, function(response){
response.on('error', function(thisError){
//what's the difference between thisError <<<<<<
});
});
request.on('error', function(thatError){
//and thatError <<<<<
});
Run Code Online (Sandbox Code Playgroud)
在请求期间,您解析名称,建立连接,发送一堆数据,每个任务都可能导致错误.
通过响应对象接收数据时,另一端可能会意外关闭连接.
这些错误是不同的,它们必须属于正确的结构,在这种情况下分别是请求和响应.