Description
In fetch.ts (line 464), the redirect host header update uses a case-sensitive key lookup:
if (headers['host'])
headers['host'] = locationURL.host;
This is inconsistent with the rest of the file, where every other header operation uses case-insensitive lookup:
setHeader() (line 935): uses Object.entries().find(pair => pair[0].toLowerCase() === name.toLowerCase())
getHeader() (line 943): same
removeHeader() (line 948): same
If extraHTTPHeaders or any other header source sets 'Host' (capital H), headers['host'] (lowercase) returns undefined, and the host header is never updated for the redirect target. The redirect request retains the original host header unmodified.
Impact
- Redirects from
https://example.com/page to https://api.example.com/data will send Host: example.com instead of Host: api.example.com
- This causes connection failures or incorrect routing for any cross-origin redirect where the Host header was set with non-lowercase casing
- Particularly impacts users who set custom
extraHTTPHeaders via browserContext.setExtraHTTPHeaders()
- The fix is a one-line change
Suggested Fix
const hostKey = Object.keys(headers).find(k => k.toLowerCase() === 'host');
if (hostKey)
headers[hostKey] = locationURL.host;
This matches the pattern used by setHeader, getHeader, and removeHeader in the same file.
Description
In
fetch.ts(line 464), the redirect host header update uses a case-sensitive key lookup:This is inconsistent with the rest of the file, where every other header operation uses case-insensitive lookup:
setHeader()(line 935): usesObject.entries().find(pair => pair[0].toLowerCase() === name.toLowerCase())getHeader()(line 943): sameremoveHeader()(line 948): sameIf
extraHTTPHeadersor any other header source sets'Host'(capital H),headers['host'](lowercase) returnsundefined, and the host header is never updated for the redirect target. The redirect request retains the original host header unmodified.Impact
https://example.com/pagetohttps://api.example.com/datawill sendHost: example.cominstead ofHost: api.example.comextraHTTPHeadersviabrowserContext.setExtraHTTPHeaders()Suggested Fix
This matches the pattern used by
setHeader,getHeader, andremoveHeaderin the same file.