Skip to content

Commit

Permalink
feat: add secure cookie override to agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Eladio Mora committed Oct 3, 2019
1 parent db35cdc commit fee770a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"zuul": "^3.12.0"
},
"engines": {
"node": ">= 6.4.0"
"node": ">= 7.0.0"
},
"homepage": "https://github.com/visionmedia/superagent",
"husky": {
Expand Down
6 changes: 5 additions & 1 deletion src/node/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ function Agent(options) {
if (options.cert) {
this.cert(options.cert);
}

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

Expand Down Expand Up @@ -76,7 +80,7 @@ Agent.prototype._attachCookies = function(req) {
const access = new CookieAccessInfo(
url.hostname,
url.pathname,
url.protocol === 'https:'
url.protocol === 'https:' || this._secureCookie
);
const cookies = this.jar.getCookies(access).toValueString();
req.cookies = cookies;
Expand Down
13 changes: 13 additions & 0 deletions src/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,19 @@ Request.prototype.cert = function(cert) {
return this;
};

/**
* Set the secure cookie override for https request
*
* @param {Boolean} secureCookie
* @return {Request} for chaining
* @api public
*/

Request.prototype.secureCookie = function(secureCookie) {
this._secureCookie = secureCookie;
return this;
};

/**
* Return an http[s] request.
*
Expand Down

0 comments on commit fee770a

Please sign in to comment.