Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HPE_HEADER_OVERFLOW exception when make http.request

Tags:

http

node.js

When I tried to get data from REST service, i meet the HPE_HEADER_OVERFLOW error as follow:

error

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.

like image 940
Steve Gao Avatar asked Feb 11 '16 00:02

Steve Gao


2 Answers

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.

like image 118
loadaverage Avatar answered Oct 18 '22 09:10

loadaverage


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

like image 7
rahulroy9202 Avatar answered Oct 18 '22 10:10

rahulroy9202