You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Undici explicitly supports headers passed as a Headers object, but the RedirectHandler does not account for this object type in its internal cleanRequestHeaders function.
Reproducible By
Configure global dispatcher to use redirect interceptor
Use undici.request to send a request with headers constructed via new Headers(...)
For headers constructed with new Headers(...), the typeof headers === 'object' condition will return true, but Object.keys(...) does not behave as expected on a Headers object. As a result, this for loop does not push any keys/values into ret.
Environment
macOS 15.0.1 (current)
Node v20.16.0 (LTS, but two minors behind)
Additional context
The text was updated successfully, but these errors were encountered:
Bug Description
Undici explicitly supports headers passed as a Headers object, but the
RedirectHandler
does not account for this object type in its internal cleanRequestHeaders function.Reproducible By
Configure global dispatcher to use redirect interceptor
Use
undici.request
to send a request with headers constructed vianew Headers(...)
Your local test server should see
'x-my-header': 'true'
in the request headersYour local test server should respond with a
3xx
statusCode and alocation: '/local/test/alt-url'
headerUndici should follow the redirect and make a request to the new location
Your local test server WILL NOT see
'x-my-header': 'true'
in the request headersCompare to:
same as above
Send the request this way instead:
same as above
same as above
same as above
Your local test server WILL see
'x-my-header': 'true'
in the request headersExpected Behavior
Logs & Screenshots
I believe I've tracked this down to this logic inside
cleanRequestHeaders
:For
headers
constructed withnew Headers(...)
, thetypeof headers === 'object'
condition will returntrue
, butObject.keys(...)
does not behave as expected on aHeaders
object. As a result, this for loop does not push any keys/values intoret
.Environment
Additional context
The text was updated successfully, but these errors were encountered: