jb55/node-bitcoin — Issue #9: handle html responses gracefully
Author: freewil
Created: 2012-02-23 16:24:32+00:00
State: open

Bitcoin will return HTML in some instances instead of JSON as expected currently. One such case is when invalid RPC credentials are sent to the bitcoin client resulting in the following response:

```html

Error

401 Unauthorized.

```

Right now the following error occurs:

```

undefined:1

^
SyntaxError: Unexpected token <
at Object.parse (native)
at IncomingMessage. (lib/jsonrpc.js:62:28)
at IncomingMessage.emit (events.js:88:20)
at HTTPParser.onMessageComplete (http.js:137:23)
at Socket.ondata (http.js:1150:24)
at TCP.onread (net.js:354:27)

```