[Bug]: Electron net.fetch can't handle non-ASCII characters in headers #42244
Labels
30-x-y
31-x-y
bug 🪲
component/net
has-repro-gist
Issue can be reproduced with code at https://gist.github.com/
status/confirmed
A maintainer reproduced the bug or agreed with the feature
Preflight Checklist
Electron Version
30.0.6
What operating system are you using?
Windows
Operating System Version
Windows 10 22H2 19045.4291
What arch are you using?
x64
Last Known Working Electron version
Unknown
Expected Behavior
Electron should encode unsupported characters in HTTP headers so that they do not cause uncaught errors
Actual Behavior
Electron does not check HTTP headers, and because of this, Node.js throws unexpected errors. This can be worked around by encoding headers in
webRequest.onHeadersReceived
, but it won't work, for example, on a modified User Agent.When
net.fetch
is replaced with the regularfetch
from Node.js, this issue does not occur for HTTP requests (just like in web browsers). Unfortunately, in Node.js, it is not possible to set non-ASCII headers, and I cannot demonstrate this example.I understand that using non-ASCII headers is against the HTTP standard, but sometimes servers send such headers (e.g., when a file being downloaded has a non-standard name and that name is placed in the header), and developers using Electron cannot cover all cases (such as a wrong User Agent).
Testcase Gist URL
https://gist.github.com/shadaxv/742cd824de5a8dfc7893c40432ee4ce1
Additional Information
There was a similar ticket, but it was closed, I am sending this as a new issue to better mark the details in the template
#39469
webRequest.onHeadersReceived
workaround:The text was updated successfully, but these errors were encountered: