static void on_xio_open_complete()

in src/uhttp.c [808:837]


static void on_xio_open_complete(void* context, IO_OPEN_RESULT open_result)
{
    /* Codes_SRS_UHTTP_07_049: [ If not NULL uhttp_client_open shall call the on_connect callback with the callback_ctx, once the underlying xio's open is complete. ] */
    if (context != NULL)
    {
        HTTP_CLIENT_HANDLE_DATA* http_data = (HTTP_CLIENT_HANDLE_DATA*)context;
        if (open_result == IO_OPEN_OK)
        {
            /* Codes_SRS_UHTTP_07_042: [ If the underlying socket opens successfully the on_connect callback shall be call with HTTP_CALLBACK_REASON_OK... ] */
            if (http_data->on_connect != NULL)
            {
                http_data->on_connect(http_data->connect_user_ctx, HTTP_CALLBACK_REASON_OK);
            }
            http_data->recv_msg.recv_state = state_open;
            http_data->connected = 1;
        }
        else
        {
            /* Codes_SRS_UHTTP_07_043: [ Otherwise on_connect callback shall be call with HTTP_CLIENT_OPEN_REQUEST_FAILED. ] */
            if (http_data->on_connect != NULL)
            {
                http_data->on_connect(http_data->connect_user_ctx, HTTP_CALLBACK_REASON_OPEN_FAILED);
            }
        }
    }
    else
    {
        LogError("Context on_xio_open_complete is NULL");
    }
}