check return code on CURLINFO_RESPONSE_CODE and add helper function for it
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 7 Mar 2012 17:06:33 +0000 (17:06 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 7 Mar 2012 17:06:33 +0000 (17:06 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@69008 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore_con/ecore_con_private.h
src/lib/ecore_con/ecore_con_url.c

index 1c6937a..91f5d39 100644 (file)
@@ -207,6 +207,7 @@ struct _Ecore_Con_Url
    Eina_List *response_headers;
    const char *url;
    long proxy_type;
+   int status;
 
    Ecore_Timer *timer;
 
index a541db6..90e8447 100644 (file)
@@ -1267,19 +1267,29 @@ 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);