     startJson = jsonPart.indexOf '{'
     endJson = jsonPart.lastIndexOf '}'
     json = jsonPart.substring startJson, endJson+1
-    console.log json
     return [null, JSON.parse(json)]
 
 

    data = []
    permissions = false
    req.on 'data', (chunk) =>
        console.log 'data'
        if permissions
            stream.emit 'data', chunk
        else

            unless err
                # Check doc
                err = checkPermissions req, doc.docType
                if err
                    # Device isn't authorized
                    res.send 403, err
                    stream.emit 'end'
                    couchReq.end()
