Skip to content

Commit

Permalink
Only iterate headers once
Browse files Browse the repository at this point in the history
  • Loading branch information
kanongil authored and Marsup committed Apr 10, 2024
1 parent 7da1633 commit 487b6f5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,15 @@ internals.Client = class {
}

uri.method = method.toUpperCase();
uri.headers = Object.assign({}, options.headers);
uri.headers = Object.create(null);

const usedHeaders = new Set();
for (const [key, value] of Object.entries(uri.headers)) {
if (value !== undefined) {
usedHeaders.add(key.toLowerCase());
if (options.headers) {
for (const [key, value] of Object.entries(options.headers)) {
if (value !== undefined) {
uri.headers[key] = value;
usedHeaders.add(key.toLowerCase());
}
}
}

Expand Down

0 comments on commit 487b6f5

Please sign in to comment.