How to use the cookiejar.CookieJar function in cookiejar

To help you get started, we’ve selected a few cookiejar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AntSwordProject / antSword / node_modules / superagent / lib / node / index.js View on Github external
const auth = url.auth.split(':');
    this.auth(auth[0], auth[1]);
  }
  if (this.username && this.password) {
    this.auth(this.username, this.password);
  }
  for (const key in this.header) {
    if (this.header.hasOwnProperty(key))
      req.setHeader(key, this.header[key]);
  }

  // add cookies
  if (this.cookies) {
    if(this.header.hasOwnProperty('cookie')) {
      // merge
      const tmpJar = new CookieJar.CookieJar();
      tmpJar.setCookies(this.header.cookie.split(';'));
      tmpJar.setCookies(this.cookies.split(';'));
      req.setHeader('Cookie',tmpJar.getCookies(CookieJar.CookieAccessInfo.All).toValueString());
    } else {
      req.setHeader('Cookie', this.cookies);
    }
  }

  return req;
};
github concur / skipper / node_modules / superagent / lib / node / index.js View on Github external
const auth = url.auth.split(':');
    this.auth(auth[0], auth[1]);
  }
  if (this.username && this.password) {
    this.auth(this.username, this.password);
  }
  for (const key in this.header) {
    if (this.header.hasOwnProperty(key))
      req.setHeader(key, this.header[key]);
  }

  // add cookies
  if (this.cookies) {
    if(this.header.hasOwnProperty('cookie')) {
      // merge
      const tmpJar = new CookieJar.CookieJar();
      tmpJar.setCookies(this.header.cookie.split(';'));
      tmpJar.setCookies(this.cookies.split(';'));
      req.setHeader('Cookie',tmpJar.getCookies(CookieJar.CookieAccessInfo.All).toValueString());
    } else {
      req.setHeader('Cookie', this.cookies);
    }
  }

  return req;
};
github chaijs / chai-http / dist / chai-http.js View on Github external
Assertion.addMethod('cookie', function (key, value) {
    var header = getHeader(this._obj, 'set-cookie')
      , cookie;

    if (!header) {
       header = (getHeader(this._obj, 'cookie') || '').split(';');
    }

    cookie = Cookie.CookieJar();
    cookie.setCookies(header);
    cookie = cookie.getCookie(key, new Cookie.CookieAccessInfo());

    if (arguments.length === 2) {
      this.assert(
          cookie.value == value
        , 'expected cookie \'' + key + '\' to have value #{exp} but got #{act}'
        , 'expected cookie \'' + key + '\' to not have value #{exp}'
        , value
        , cookie.value
      );
    } else {
      this.assert(
          'undefined' !== typeof cookie || null === cookie
        , 'expected cookie \'' + key + '\' to exist'
        , 'expected cookie \'' + key + '\' to not exist'
github chaijs / chai-http / lib / http.js View on Github external
Assertion.addMethod('cookie', function (key, value) {
    var header = getHeader(this._obj, 'set-cookie')
      , cookie;

    if (!header) {
       header = (getHeader(this._obj, 'cookie') || '').split(';');
    }

    if (this._obj instanceof chai.request.agent && this._obj.jar) {
      cookie = this._obj.jar.getCookie(key, Cookie.CookieAccessInfo.All);
    } else {
      cookie = Cookie.CookieJar();
      cookie.setCookies(header);
      cookie = cookie.getCookie(key, Cookie.CookieAccessInfo.All);
    }

    if (arguments.length === 2) {
      this.assert(
          cookie.value == value
        , 'expected cookie \'' + key + '\' to have value #{exp} but got #{act}'
        , 'expected cookie \'' + key + '\' to not have value #{exp}'
        , value
        , cookie.value
      );
    } else {
      this.assert(
          'undefined' !== typeof cookie || null === cookie
        , 'expected cookie \'' + key + '\' to exist'
github concur / skipper / node_modules / chai-http / lib / http.js View on Github external
Assertion.addMethod('cookie', function (key, value) {
    var header = getHeader(this._obj, 'set-cookie')
      , cookie;

    if (!header) {
       header = (getHeader(this._obj, 'cookie') || '').split(';');
    }

    if (this._obj instanceof chai.request.agent && this._obj.jar) {
      cookie = this._obj.jar.getCookie(key, Cookie.CookieAccessInfo.All);
    } else {
      cookie = Cookie.CookieJar();
      cookie.setCookies(header);
      cookie = cookie.getCookie(key, Cookie.CookieAccessInfo.All);
    }

    if (arguments.length === 2) {
      this.assert(
          cookie.value == value
        , 'expected cookie \'' + key + '\' to have value #{exp} but got #{act}'
        , 'expected cookie \'' + key + '\' to not have value #{exp}'
        , value
        , cookie.value
      );
    } else {
      this.assert(
          'undefined' !== typeof cookie || null === cookie
        , 'expected cookie \'' + key + '\' to exist'
github nfriedly / nfriedly.com / node_modules / docpad / node_modules / superagent / lib / node / agent.js View on Github external
function Agent(options) {
  if (!(this instanceof Agent)) return new Agent(options);
  if (options) this._ca = options.ca;
  this.jar = new CookieJar;
}
github AntSwordProject / antSword / node_modules / superagent / lib / node / agent.js View on Github external
function Agent(options) {
  if (!(this instanceof Agent)) {
    return new Agent(options);
  }
  AgentBase.call(this);
  this.jar = new CookieJar();

  if (options) {
    if (options.ca) {this.ca(options.ca);}
    if (options.key) {this.key(options.key);}
    if (options.pfx) {this.pfx(options.pfx);}
    if (options.cert) {this.cert(options.cert);}
  }
}
github MindFreakers / cdn / node_modules / superagent / lib / node / agent.js View on Github external
function Agent(options) {
  if (!(this instanceof Agent)) return new Agent(options);
  if (options) {
    this._ca = options.ca;
    this._key = options.key;
    this._pfx = options.pfx;
    this._cert = options.cert;
  }
  this.jar = new CookieJar;
}
github visionmedia / superagent / src / node / agent.js View on Github external
function Agent(options) {
  if (!(this instanceof Agent)) {
    return new Agent(options);
  }

  AgentBase.call(this);
  this.jar = new CookieJar();

  if (options) {
    if (options.ca) {
      this.ca(options.ca);
    }

    if (options.key) {
      this.key(options.key);
    }

    if (options.pfx) {
      this.pfx(options.pfx);
    }

    if (options.cert) {
      this.cert(options.cert);
github visionmedia / superagent / lib / node / agent.js View on Github external
function Agent(options) {
  if (!(this instanceof Agent)) {
    return new Agent(options);
  }
  AgentBase.call(this);
  this.jar = new CookieJar();

  if (options) {
    if (options.ca) {this.ca(options.ca);}
    if (options.key) {this.key(options.key);}
    if (options.pfx) {this.pfx(options.pfx);}
    if (options.cert) {this.cert(options.cert);}
  }
}

cookiejar

simple persistent cookiejar system

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis

Similar packages