Reputation: 595
When I tried to get data from REST service, i meet the HPE_HEADER_OVERFLOW error as follow:
var options = {
host: "something.com",
port: 80,
path: "/somepath...",
method: 'POST'
};
var request = http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function(chunk) {
// Do something
});
res.on('end', function() {
// Do something
});
request.on('error', function(e) {
// Do something
});
});
request.end();
The length of path parameter in the options is 413.
Does anyone meet this issue? Is this service-side issue or node-side issue?
Please give some idea about it, thanks a lot.
Upvotes: 9
Views: 14994
Reputation: 99
Use Base64 encoding for the Header data which is causing HPE_HEADER_OVERFLOW
like below:
headers: {Cookie: Buffer.from('_oauth2******************************2YJ9Y=').toString('base64')}
Upvotes: 0
Reputation:
I have the same question, but my backend script is PHP. And I return the response header with some internal information including SQL and internal API url, thus the reponse headers is so big that exceeds the max-header-size and encountered this error. You can consider minishing the response header size in some case
Upvotes: 0
Reputation: 21
After digging a bit, the default parser node uses is the problem. The solution is to get a new parser:
npm install http-parser-js
then, just before you require http/https, change the parser. You have to end up having something similar to this:
process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser
const https = require('https')
If for some reason you want to use node's default parser, assuming your file is called 'app.js', you must use the header size flag like this:
node --max-http-header-size=81000 app.js
Upvotes: 2
Reputation: 2848
node app.js --max-http-header-size=80000
They made the header size configurable. Check the following links.
https://nodejs.org/api/cli.html#cli_max_http_header_size_size
https://github.com/nodejs/node/issues/24692
Upvotes: 8
Reputation: 1035
I think you'll find more stuff here and here
In a nutshell, Node.js has 80 KB limit for headers size which are big enough for most requests on the web (for example Apache has 8190 bytes limit).
If that service somehow has so huge headers you can recompile node with -DHTTP_MAX_HEADER_SIZE=xxxx
argument.
Upvotes: 7