tcr / rem

HTTP clients with middleware for Node.js and web browsers. Flexible for any HTTP request, customizable for building API clients, and supports OAuth.
MIT License
25 stars 11 forks source link

blank content on callback error #82

Closed jiahuang closed 11 years ago

jiahuang commented 11 years ago

I'm getting an error when I call github's webhook delete request. http://developer.github.com/v3/repos/hooks/#delete-a-hook It returns a 204, no content and from looking through the source of rem-js, it looks like it's trying to parse the blank content. Not quite sure about it though.

The delete requests are getting through to github, so the call was properly sent, it just fails on the callback.

Here's the error log

03:19:48 web.1 | Invalid JSON: 03:19:48 web.1 | 03:19:48 web.1 | /Users/jialiya/projects/issue-hoard/node_modules/rem/src/rem.js:211 03:19:48 web.1 | throw e; 03:19:48 web.1 | ^ 03:19:48 web.1 | SyntaxError: Unexpected end of input 03:19:48 web.1 | at Object.parse (native) 03:19:48 web.1 | at rem.parsers.json (/Users/jialiya/projects/issue-hoard/node_modules/rem/src/rem.js:208:21) 03:19:48 web.1 | at rem.parsers.text (/Users/jialiya/projects/issue-hoard/node_modules/rem/src/rem.js:201:7) 03:19:48 web.1 | at Stream.env.consumeStream (/Users/jialiya/projects/issue-hoard/node_modules/rem/src/node/env.js:20:5) 03:19:48 web.1 | at Stream.EventEmitter.emit (events.js:115:20) 03:19:48 web.1 | at OAuth2API.send (/Users/jialiya/projects/issue-hoard/node_modules/rem/src/node/oauth.js:442:16) 03:19:48 web.1 | at passBackControl (/Users/jialiya/projects/issue-hoard/node_modules/rem/node_modules/oauth/lib/oauth2.js:68:9) 03:19:48 web.1 | at IncomingMessage.exports.OAuth2._request.request.on.callbackCalled (/Users/jialiya/projects/issue-hoard/node_modules/rem/node_modules/oauth/lib/oauth2.js:85:7)

tcr commented 11 years ago

This is fixed in npm now. Empty content bodies return null instead of JSON or XML content.