Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this error mean: HPE_INVALID_CONSTANT?

Tags:

http

tcp

I was receiving HPE_INVALID_CONSTANT when making HTTP requests with NodeJS the other day. They mysteriously stopped occurring recently, but I'm still baffled and curious what exactly HPE_INVALID_CONSTANT is trying to tell me.

My google search results are a bit slanted towards NodeJS, so I'm not picking up anything that describes more generally what this means. It looks like a system level error since it's all caps.

like image 738
Breedly Avatar asked Jan 13 '16 14:01

Breedly


3 Answers

The HPE_INVALID_CONSTANT means Http Parse Error and the invalid constant means that the response is malformed. So the parser can't parse it!

like image 63
Miguel Carvajal Avatar answered Oct 21 '22 03:10

Miguel Carvajal


Think this answer is lated, but it can help some people.

I also had this problem and realized NodeJS doesn't support HTTP 0.9, that server's response contains no headers. In fact, in NodeJS documentation shows support to 1.0 and 1.1 http requests.

You can read a little more here in this issue.

like image 24
Luiz Fernando da Silva Avatar answered Oct 21 '22 03:10

Luiz Fernando da Silva


I encountered this issue because I was trying to compress files that were too small. In my specific case, I was creating a readstream of a file that was 83 bytes, and then piping it into a gzip, before finally piping it into the response

fs.createReadStream(file_path).pipe(gzip.createGzip()).pipe(res);

On the requester side, I was then trying to unzip the file

stream = request({"url": "https://example.com/getFile", "timeout": 200000});

//This is where the error was getting thrown
stream.pipe(gzip.createGunzip())

It seems that trying to compress and then decompress a file with a size somewhere less than 200 bytes will totally break this, so that was a gotcha I encountered. I guess the moral of my story is don't compress files that are super tiny!

like image 1
Big Sam Avatar answered Oct 21 '22 03:10

Big Sam