質問

I am doing a JSON call using the request module in NodeJS but was getting

Error: Parse Error
    at Socket.socketOnData (http.js:1367:20)
    at TCP.onread (net.js:403:27)

and the process would exit without getting the response. I put in a

process.on('uncaughtException', function(e){
    console.log(JSON.stringify(e, null, ' '))
})

and got this as the trace ..

Parse Error
{
 "bytesParsed": 238,
 "code": "HPE_INVALID_CONSTANT"
}

I tried putting in a try catch block around the get call but that did not work. Once I started catching the 'uncaughtException' I got the stack trace and then the JSON response for the call. Please help me identify why this is happening and how I can efficiently handle it. I am using node v0.8.12

役に立ちましたか?

解決

HPE_INVALID_CONSTANT means that either the server sent 'HTTP/1.0' at the wrong time or that the Content-Length header was wrong. Either way, it's a problem with the server and its response that will need to be fixed on the server side.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top