check return code on CURLINFO_RESPONSE_CODE and add helper function for it

SVN revision: 69008
This commit is contained in:
Mike Blumenkrantz 2012-03-07 17:06:33 +00:00
parent 8217a140a0
commit 894bfaeed7
2 changed files with 14 additions and 3 deletions

View File

@ -207,6 +207,7 @@ struct _Ecore_Con_Url
Eina_List *response_headers;
const char *url;
long proxy_type;
int status;
Ecore_Timer *timer;

View File

@ -1266,20 +1266,30 @@ ecore_con_url_proxy_password_set(Ecore_Con_Url *url_con, const char *password)
*/
#ifdef HAVE_CURL
static void
_ecore_con_url_status_get(Ecore_Con_Url *url_con)
{
long status = 0;
if (curl_easy_getinfo(url_con->curl_easy, CURLINFO_RESPONSE_CODE, &status))
url_con->status = status;
}
static void
_ecore_con_url_event_url_complete(Ecore_Con_Url *url_con, CURLMsg *curlmsg)
{
Ecore_Con_Event_Url_Complete *e;
long status = 0;
e = calloc(1, sizeof(Ecore_Con_Event_Url_Complete));
if (!e) return;
if (curlmsg && (curlmsg->data.result == CURLE_OK))
curl_easy_getinfo(curlmsg->easy_handle, CURLINFO_RESPONSE_CODE, &status);
{
if (!url_con->status)
_ecore_con_url_status_get(url_con);
}
else ERR("Curl message have errors: %d", curlmsg->data.result);
e->status = status;
e->status = url_con->status;
e->url_con = url_con;
url_con->event_count++;
ecore_event_add(ECORE_CON_EVENT_URL_COMPLETE, e, (Ecore_End_Cb)_ecore_con_event_url_free, url_con);