couch-client icon indicating copy to clipboard operation
couch-client copied to clipboard

HEAD requests fail

Open diversario opened this issue 14 years ago • 1 comments

When I try to perform a HEAD request I get this:

undefined:0

^
SyntaxError: Unexpected end of input
    at Object.parse (native)
    at IncomingMessage.<anonymous> (/usr/local/lib/node/.npm/couch-client/0.0.4/package/lib/cou ch-client.js:80:45)
    at IncomingMessage.emit (events.js:81:20)
    at HTTPParser.onMessageComplete (http.js:132:23)
    at Socket.ondata (http.js:1206:22)
    at Socket._onReadable (net.js:675:27)
    at IOWatcher.onReadable [as callback] (net.js:177:10)

Does couch-client support HEAD requests?

diversario avatar Mar 29 '11 18:03 diversario

I came across this as well. I wanted the response status from HEAD requests so I changed line 81 in my copy of lib/couch-client.js to:

    if (callback) {
      if (options.method === 'HEAD') {
        callback(null, response.statusCode);
      } else {
        callback(null, JSON.parse(body));
      }
    }

jacksonp avatar Oct 13 '11 13:10 jacksonp