服务器以未处理状态响应:400,在nodejs中进行wget-improved

时间:2016-05-10 11:21:33

标签: node.js npm wget

'wget-improved'上尝试node.js模块时,我会在错误函数上获得Server responded with unhandled status: 400

这里是fileToDownload,fileUrl是'public / assets /

var wget = require('wget-improved');
var options = {
    protocol: 'http',
    headers :{'User-Agent': 'Node'},
    method: 'GET'
};

 var download = wget.download(fileToDownload, fileUrl, options);

    download.on('error', function(err) {

        console.log("error download");
        console.log(err);
                    var data = {
                        "CODE": 0,
                        "error": "error download"
                    }

        return;

    });

    download.on('start', function(fileSize) {
        console.log("file downloaded ")
        console.log(fileSize);

    });

    download.on('end', function(output) {
        console.log(output);
        var data = {
             "CODE": 1
          };


        return;


    });
    download.on('progress', function(progress) {
        // code to show progress bar


    });`

0 个答案:

没有答案