agent-base.js 622 B

1234567891011121314151617181920
  1. function Agent() {
  2. this._defaults = [];
  3. }
  4. ["use", "on", "once", "set", "query", "type", "accept", "auth", "withCredentials", "sortQuery", "retry", "ok", "redirects",
  5. "timeout", "buffer", "serialize", "parse", "ca", "key", "pfx", "cert"].forEach(function(fn) {
  6. /** Default setting for all requests from this agent */
  7. Agent.prototype[fn] = function(/*varargs*/) {
  8. this._defaults.push({fn:fn, arguments:arguments});
  9. return this;
  10. }
  11. });
  12. Agent.prototype._setDefaults = function(req) {
  13. this._defaults.forEach(function(def) {
  14. req[def.fn].apply(req, def.arguments);
  15. });
  16. };
  17. module.exports = Agent;