Skip to content
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

Invalid header character with strange "equals" header in builtin node js http library #3457

Open
iocmet opened this issue Jul 6, 2023 · 3 comments

Comments

@iocmet
Copy link

iocmet commented Jul 6, 2023

Summary

When i tried send discord message with bot token that contains file i ran into this exception
throw new Error(error);
^

Error: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["equals"]
at Request._callback (/data/data/com.termux/files/home/Parser-Bot/node_modules/async-request/src/main.js:24:27)
at self.callback (/data/data/com.termux/files/home/Parser-Bot/node_modules/request/request.js:185:22)
at Request.emit (node:events:523:35)
at Request.start (/data/data/com.termux/files/home/Parser-Bot/node_modules/request/request.js:753:10)
at Request.write (/data/data/com.termux/files/home/Parser-Bot/node_modules/request/request.js:1491:10)
at FormData.ondata (node:internal/streams/legacy:20:31)
at FormData.emit (node:events:511:28)
at CombinedStream.write (/data/data/com.termux/files/home/Parser-Bot/node_modules/combined-stream/lib/combined_stream.js:138:8)
at CombinedStream._pipeNext (/data/data/com.termux/files/home/Parser-Bot/node_modules/combined-stream/lib/combined_stream.js:126:8)
at CombinedStream._realGetNext (/data/data/com.termux/files/home/Parser-Bot/node_modules/combined-stream/lib/combined_stream.js:99:10)

Simplest Example to Reproduce

Im not sure why it happening but you can try send discord message with file

Expected Behavior

POST request will just be send

Current Behavior

Invalid character in header content error

Possible Solution

I don't know

Context

Send discord message from bot account with file (maybe send POST with multipart/form-data type is more correct but i successfully do this using request before)

Your Environment

software version
request latest
node 20.2.0
npm 9.6.6
Operating System
Android armv8 (not matters at all i think)
@iocmet
Copy link
Author

iocmet commented Jul 7, 2023

After recursive code commenting and running script i found that this line causes error (still looking for most low level reason)

@iocmet
Copy link
Author

iocmet commented Jul 7, 2023

For some strange reason "equals" method is being added to headers, self.headers:

{
... other headers
equals: [Function: objectEquals]
}

@iocmet
Copy link
Author

iocmet commented Jul 7, 2023

Root of problem is in caseless package and it happened because i declared equals method in Object prototype, you can access objects from prototype with for loop or like obj['protoValue']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant