creationix/http-parser-js

using on Node-Red

dandres16 opened this issue · 4 comments

Someone has used this module in node-red?, I have tried to use it with the function block but I do not have good results. Helpme please

This module has very little use outside of as a monkey-patch for Node's HTTP parser, which must be done immediately at startup before loading any other code. I'm not familiar with Node-Red, but it looks like a larger framework, and if you want to use this module you'd need to modify its code to do the monkey-patching before loading any of its own modules.

What are you trying to accomplish?

This module has very little use outside of as a monkey-patch for Node's HTTP parser, which must be done immediately at startup before loading any other code. I'm not familiar with Node-Red, but it looks like a larger framework, and if you want to use this module you'd need to modify its code to do the monkey-patching before loading any of its own modules.

What are you trying to accomplish?

Thanks
When I use the http request block, Node-Red gives me the error hpe_invalid_header_token.
I tested this module in node.js and it works perfectly, but I can not find how to implement it in node-red

I think you would probably have to modify and build Node-Red from source - looks like the very first line of their main script (red.js) does a require('http') and http-parser-js needs to be inserted before anyone requires http.

I suspect that's as simple as downloading Node-red from here, adding http-parser-js (run npm i http-parser-js) and modifying red.js so that the first line is the monkey patching described here. Then build (npm run build) and run (npm start).

I'd previously seen people talk of a pure-JS full http stack (not just the parser), which could be used instead of Node's, not sure if that every got finished, but if you find one of those, it would probably also solve your problem, though may be even harder to integrate with Node-Red.

Thanks for your help, I will try to implement your solution