-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: handle Headers in RedirectHandler #3777
Conversation
e4ddac9
to
c1c78c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests for it?
b941ad4
to
71c9baf
Compare
lib/handler/redirect-handler.js
Outdated
@@ -239,3 +240,4 @@ function cleanRequestHeaders (headers, removeContent, unknownOrigin) { | |||
} | |||
|
|||
module.exports = RedirectHandler | |||
module.exports.cleanRequestHeaders = cleanRequestHeaders |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not do that if we are just exporting it to testing it out.
You can attempt to test the same on the redirect-request
test suite where you submit a Headers
instance instead of the array/object way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests in appropriate file
7c891d5
to
e4768c4
Compare
@@ -227,9 +227,10 @@ function cleanRequestHeaders (headers, removeContent, unknownOrigin) { | |||
} | |||
} | |||
} else if (headers && typeof headers === 'object') { | |||
for (const key of Object.keys(headers)) { | |||
const entries = headers instanceof Headers ? headers.entries() : Object.entries(headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't work for Maps, only Headers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better to check for Symbol.Iterable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iiAku can you create a follow up PR?
const entries = utils.isIterable(headers) ? headers : Object.entries(headers)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this also only works with the global Headers, not Headers imported from undici
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iiAku can you create a follow up PR?
const entries = utils.isIterable(headers) ? headers : Object.entries(headers)
Yes I can look into this, thanks for reviewing raising that point @KhafraDev
This relates to...
This should close #3773
Rationale
Changes
Features
Bug Fixes
Breaking Changes and Deprecations
Status