         return
 
       response.on 'close', (err) ->
-        return if callbacked
+        return if hasEnded
         callback({
           error: 'close'
           message: err
         })
-        callbacked = true
         return
 
       response.on 'end', ->
+        hasEnded = true
         chunks = chunks.join('')
         if response.statusCode isnt 200
-          return if callbacked
           callback({
             error: 'bad status code'
             detail: response.statusCode
             message: chunks
           })
-          callbacked = true
           return
 
         try
           chunks = JSON.parse(chunks)
         catch e
-          return if callbacked
           callback({
             error: 'json parse'
             message: e.message
           })
-          callbacked = true
           return
 
-        return if callbacked
         callback(null, chunks)
-        callbacked = true
         return
       return
     )

        socket.on 'timeout', -> req.abort()

    req.on 'error', (e) ->
      return if callbacked
      callback(e)
      callbacked = true
      return

    req.write(queryBuffer.toString('utf-8'))

      }
    }
    req = http.request(opts, (response) ->
      hasEnded = false
      # response.statusCode
      # response.headers
      # response.statusCode
