dscape/nano — Issue #47: incorrect failure condition in latest code
Author: perezd
Created: 2012-01-02 23:34:44+00:00
State: open

HEAD requests have empty bodies, seen below:

```
>>
{ method: 'HEAD',
headers:
{ 'content-type': 'application/json',
accept: 'application/json' },
uri: 'http://admin:admin@localhost:5984/orchestra-tests-master-profile-mappings/pm-d373c6bf6346cd8da895d3ec0f73cc92' }
<<
{ err: 'couch',
body: undefined,
headers:
{ date: 'Mon, 02 Jan 2012 23:30:34 GMT',
'content-type': 'application/json',
'cache-control': 'must-revalidate',
'status-code': 404 } }
```

I receive the following error:

```
uncaught undefined: TypeError: Cannot read property 'reason' of undefined
at Request._callback (/node_modules/nano/nano.js:167:38)
at Request.callback (/node_modules/nano/node_modules/request/main.js:99:22)
at Request. (/node_modules/nano/node_modules/request/main.js:361:18)
at Request.emit (events.js:64:17)
at IncomingMessage. (/node_modules/nano/node_modules/request/main.js:327:16)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at Socket.ondata (http.js:1231:22)
at Socket._onReadable (net.js:683:27)
at IOWatcher.onReadable [as callback] (net.js:177:10)
```

I believe this code is trying to signal an error, however, in the case of a HEAD request, this should not be relying on the existence of a body, since by definition, a HEAD request will only return headers in CouchDB. Thoughts?