src/elastic-connection.c
static void
elastic_connection_payload_input(struct elastic_connection *conn)
{
    FUNC_START();
    const unsigned char *data = NULL;
    json_object *jobj = NULL;
    enum json_tokener_error jerr;
    size_t size;
    int ret = -1;

    /* continue appending data so long as it is available */
    while ((ret = i_stream_read_data(conn->payload, &data, &size, 0)) > 0) {
        jobj = json_tokener_parse_ex(conn->tok, (const char *)data, size);
        i_stream_skip(conn->payload, size);

        jerr = json_tokener_get_error(conn->tok);
        if (jerr == json_tokener_continue) {
            if (ret < 0)
                i_error("fts_elastic: json response not finished");
        } else if (jerr == json_tokener_success) {
            /* extract values from resulting json object */
            elastic_connection_json(conn, jobj);
        } else {
            i_error("fts_elastic: json tokener error: %s", json_tokener_error_desc(jerr));
            break;
        }
    }

    if (ret == 0) {
        /* we will be called again for more data */
    } else {
        if (conn->payload->stream_errno != 0) {
            i_error("fts_elastic: failed to read payload from HTTP server: %m");
            conn->request_status = -1;
        }

        /* clean-up */
        io_remove(&conn->io);
        i_stream_unref(&conn->payload);
    }
    FUNC_END();
}
/* Parses response payload to json from _search request */
Parses response payload to json from _search request
Parses response payload to json from _search request
static void
elastic_connection_payload_input(struct elastic_connection *conn)
{
    FUNC_START();
    const unsigned char *data = NULL;
    json_object *jobj = NULL;
    enum json_tokener_error jerr;
    size_t size;
    int ret = -1;
    while ((ret = i_stream_read_data(conn->payload, &data, &size, 0)) > 0) {
        jobj = json_tokener_parse_ex(conn->tok, (const char *)data, size);
        i_stream_skip(conn->payload, size);
        jerr = json_tokener_get_error(conn->tok);
        if (jerr == json_tokener_continue) {
            if (ret < 0)
                i_error("fts_elastic: json response not finished");
        } else if (jerr == json_tokener_success) {
            elastic_connection_json(conn, jobj);
        } else {
            i_error("fts_elastic: json tokener error: %s", json_tokener_error_desc(jerr));
            break;
        }
    }
    if (ret == 0) {
    } else {
        if (conn->payload->stream_errno != 0) {
            i_error("fts_elastic: failed to read payload from HTTP server: %m");
            conn->request_status = -1;
        }
        io_remove(&conn->io);
        i_stream_unref(&conn->payload);
    }
    FUNC_END();
}
static void elastic_connection_payload_input ( struct elastic_connection * conn ) { FUNC_START ( ) ; const unsigned char * data = NULL ; json_object * jobj = NULL ; enum json_tokener_error jerr ; size_t size ; int ret = -1 ; while ( ( ret = i_stream_read_data ( conn -> payload , & data , & size , 0 ) ) > 0 ) { jobj = json_tokener_parse_ex ( conn -> tok , ( const char * ) data , size ) ; i_stream_skip ( conn -> payload , size ) ; jerr = json_tokener_get_error ( conn -> tok ) ; if ( jerr == json_tokener_continue ) { if ( ret < 0 ) i_error ( " " ) ; } else if ( jerr == json_tokener_success ) { elastic_connection_json ( conn , jobj ) ; } else { i_error ( " " , json_tokener_error_desc ( jerr ) ) ; break ; } } if ( ret == 0 ) { } else { if ( conn -> payload -> stream_errno != 0 ) { i_error ( " " ) ; conn -> request_status = -1 ; } io_remove ( & conn -> io ) ; i_stream_unref ( & conn -> payload ) ; } FUNC_END ( ) ; }
Parses response payload to json from _search request
Parses response payload to json from _search request
/* continue appending data so long as it is available */ /* extract values from resulting json object */ /* we will be called again for more data */ /* clean-up */