コード例 #1
0
static void
http_data_callback(lcb_http_request_t req,
                   lcb_t instance,
                   const void *cookie,
                   lcb_error_t err,
                   const lcb_http_resp_t *resp)
{
    pycbc_HttpResult *htres = (pycbc_HttpResult*)cookie;

    htres->htcode = resp->v.v0.status;
    htres->rc = err;

    PYCBC_CONN_THR_END(htres->parent);

    get_headers(htres, resp);

    if (err != LCB_SUCCESS || resp->v.v0.status < 200 || resp->v.v0.status > 299) {
        PyObject *old_data = htres->http_data;

        lcbex_vrow_free(htres->rctx);
        htres->rctx = NULL;
        htres->http_data = PyList_New(0);

        if (old_data) {
            if (old_data != Py_None) {
                PyList_Append(htres->http_data, old_data);
            }
            Py_DECREF(old_data);
        }
    }

    if (htres->rctx) {
        lcbex_vrow_feed(htres->rctx, resp->v.v0.bytes, resp->v.v0.nbytes);

    } else if (resp->v.v0.bytes) {
        get_data(htres, resp->v.v0.bytes, resp->v.v0.nbytes);
    }

    if (!htres->parent->nremaining) {
        lcb_breakout(instance);
    }

    PYCBC_CONN_THR_BEGIN(htres->parent);

    (void)req;
    (void)instance;
}
コード例 #2
0
ファイル: http.c プロジェクト: hahla/couchbase-python-client
static void
http_data_callback(lcb_http_request_t req,
                   lcb_t instance,
                   const void *cookie,
                   lcb_error_t err,
                   const lcb_http_resp_t *resp)
{
    pycbc_HttpResult *htres = (pycbc_HttpResult*)cookie;

    htres->htcode = resp->v.v0.status;
    htres->rc = err;

    PYCBC_CONN_THR_END(htres->parent);

    get_headers(htres, resp);

    if (err != LCB_SUCCESS || resp->v.v0.status < 200 || resp->v.v0.status > 299) {
        lcbex_vrow_free(htres->rctx);
        htres->rctx = NULL;
    }

    if (htres->rctx) {
        lcbex_vrow_feed(htres->rctx, resp->v.v0.bytes, resp->v.v0.nbytes);
        maybe_invoke_async_callback(htres);

    } else if (resp->v.v0.bytes) {
        add_data(htres, resp->v.v0.bytes, resp->v.v0.nbytes);
    }

    if (!htres->parent->nremaining) {
        lcb_breakout(instance);
    }

    PYCBC_CONN_THR_BEGIN(htres->parent);

    (void)req;
    (void)instance;
}
コード例 #3
0
static void
HttpResult_dealloc(pycbc_HttpResult *self)
{
    pycbc_Connection *parent = self->parent;

    self->parent = NULL;

    if (self->htreq) {
        lcb_cancel_http_request(parent->instance, self->htreq);
        self->htreq = NULL;
    }

    Py_XDECREF(self->http_data);
    Py_XDECREF(parent);
    Py_XDECREF(self->headers);
    Py_XDECREF(self->rowsbuf);
    Py_XDECREF(self->callback);

    if (self->rctx) {
        lcbex_vrow_free(self->rctx);
        self->rctx = NULL;
    }
    pycbc_Result_dealloc((pycbc_Result*)self);
}