static void StatQuery_CallbackGeneric( wswcurl_req *req, int status, void *customp ) { const char *content_type; stat_query_t *query = (stat_query_t *)customp; qboolean success = status > 0 ? qtrue : qfalse; // print some stuff out if( status < 0 ) { Com_Printf( "StatQuery HTTP error: \"%s\", url \"%s\"\n", wswcurl_errorstr( status ), wswcurl_get_effective_url( req ) ); } else { // check the MIME type and see if we have JSON, if so parse it up content_type = wswcurl_get_content_type( req ); if( content_type && !strcmp( content_type, "application/json" ) ) { StatQuery_CacheResponseRaw( query ); if( query->response_raw ) query->json_in = cJSON_Parse( query->response_raw ); } } if( query->callback_fn ) query->callback_fn( query, success, query->customp ); StatQuery_DestroyQuery( query ); }
static void StatQuery_Send( stat_query_t *query ) { StatQuery_Prepare( query ); // check whether our curl request is valid (might have been delayed-allocated in StatQuery_Prepare) if( !query->req ) { if( query->callback_fn ) query->callback_fn( query, false, query->customp ); StatQuery_DestroyQuery( query ); return; } wswcurl_stream_callbacks ( query->req, NULL, StatQuery_CallbackGeneric, NULL, (void*)query ); wswcurl_start( query->req ); }