node.js - request - How to “emitter.setMaxListeners()”?

前端 未结 7 1682
忘了有多久
忘了有多久 2020-11-28 06:27

When I do a GET on a certain URI using the node.js \'request\' module;

var options = {uri:\"aURI\", headers:headerData};
request.get(options, function (error         


        
7条回答
  •  醉梦人生
    2020-11-28 06:35

    This is how I solved the problem:

    In main.js of the 'request' module I added one line:

    Request.prototype.request = function () {
      var self = this
      self.setMaxListeners(0); // Added line
    

    This defines unlimited listeners http://nodejs.org/docs/v0.4.7/api/events.html#emitter.setMaxListeners

    In my code I set the 'maxRedirects' value explicitly:

    var options = {uri:headingUri, headers:headerData, maxRedirects:100};
    

提交回复
热议问题