Request reported a mistake, what’s the matter, the official method is wrong!

  node.js, question

According to thishttps://github.com/request/requestFor example in,
You can stream any response to a file stream.

request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'))

Original document

var fs = require('fs');
 var path = require('path');
 var request = require('request');
 var cheerio = require('cheerio');
 
 request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'));

The execution of the horse is reported as follows:

stream.js:74
 throw er;  // Unhandled stream error in pipe.
 ^
 
 Error: read ECONNRESET
 at exports._errnoException (util.js:870:11)
 at TCP.onread (net.js:552:26)

node v4.4.5

The reason is simple: Google is blocked by the great The Wall

I casually changed to a picture address from Baidu and succeeded

var url = 'https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=1564909352,2801480363&fm=5';
// request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'));
request(url).pipe(fs.createWriteStream('doodle.png'));