Skip to content

Commit

Permalink
Support multiple cookies for follow_set_cookies
Browse files Browse the repository at this point in the history
It appears that cookies.js expects the format ofthe `Set Cookies` header
to function. This sounds reasonable, but the original request cookies
are stored as a string not as key-value pair strings, so it needs to be
separated again to be forwarded correctly in the redirect.
  • Loading branch information
QuiteQuiet committed Feb 8, 2023
1 parent f9d554e commit db4201d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/needle.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data,
// if follow_set_cookies is true, insert cookies in the next request's headers.
// we set both the original request cookies plus any response cookies we might have received.
if (config.follow_set_cookies && utils.host_and_ports_match(headers.location, uri)) {
var request_cookies = cookies.read(config.headers['cookie']);
var request_cookies = cookies.read(config.headers['cookie'].split(';'));
config.previous_resp_cookies = resp.cookies;
if (Object.keys(request_cookies).length || Object.keys(resp.cookies || {}).length) {
config.headers['cookie'] = cookies.write(extend(request_cookies, resp.cookies));
Expand Down

0 comments on commit db4201d

Please sign in to comment.