Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
};
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;
};
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'
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'
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'
function Agent(options) {
if (!(this instanceof Agent)) return new Agent(options);
if (options) this._ca = options.ca;
this.jar = new CookieJar;
}
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);}
}
}
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;
}
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);
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);}
}
}