Skip to content

Commit

Permalink
Make config.headers a new object, not a pointer to the defaults.heade…
Browse files Browse the repository at this point in the history
…rs object
  • Loading branch information
tomas committed Apr 8, 2020
1 parent 5d187b3 commit c1177c2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/needle.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ Needle.prototype.setup = function(uri, options) {
http_opts : {
localAddress: get_option('localAddress', undefined)
}, // passed later to http.request() directly
headers : {},
output : options.output,
proxy : get_option('proxy', defaults.proxy),
parser : get_option('parse_response', defaults.parse_response),
Expand All @@ -231,7 +232,9 @@ Needle.prototype.setup = function(uri, options) {
//////////////////////////////////////////////////
// headers, cookies

config.headers = defaults.headers || {};
for (var key in defaults.headers)
config.headers[key] = defaults.headers[key];

config.headers['accept'] = options.accept || defaults.accept;
config.headers['user-agent'] = options.user_agent || defaults.user_agent;

Expand Down

0 comments on commit c1177c2

Please sign in to comment.