Exemple #1
0
ERROR_CODE create_http_client_connection(struct http_client_connection_t **http_client_connection_pointer, struct io_connection_t *io_connection) {
    /* retrieves the http client connection size */
    size_t http_client_connection_size = sizeof(struct http_client_connection_t);

    /* allocates space for the http client connection */
    struct http_client_connection_t *http_client_connection =\
        (struct http_client_connection_t *) MALLOC(http_client_connection_size);

    /* sets the http handler attributes (default) values */
    http_client_connection->io_connection = io_connection;

    /* creates the http settings and the http parser
    (for a response) these are goint be used in the message */
    create_http_settings(&http_client_connection->http_settings);
    create_http_parser(&http_client_connection->http_parser, 0);

    /* sets the default callback functions in the http settings
    these function are going to be called by the parser */
    http_client_connection->http_settings->on_body = body_callback_handler_client;
    http_client_connection->http_settings->on_message_complete = message_complete_callback_handler_client;

    /* sets the connection as the parser parameter(s) */
    http_client_connection->http_parser->parameters = io_connection->connection;

    /* sets the http client connection in the (upper) io connection substrate */
    io_connection->lower = http_client_connection;

    /* sets the http client connection in the http client connection pointer */
    *http_client_connection_pointer = http_client_connection;

    /* raises no error */
    RAISE_NO_ERROR;
}
Exemple #2
0
MOOON_NAMESPACE_BEGIN

CGeneralParser::CGeneralParser()
{
    CGeneralEvent* general_event = new CGeneralEvent;
    _http_parser = create_http_parser(true);
    _http_parser->set_http_event(general_event);    

    reset();
}