added fuction to send httposts created with curl formadd.
authorjeffdameth <jeffdameth@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 6 May 2010 20:18:39 +0000 (20:18 +0000)
committerjeffdameth <jeffdameth@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 6 May 2010 20:18:39 +0000 (20:18 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@48651 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

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

index 7b66305..05efff0 100644 (file)
@@ -230,6 +230,7 @@ extern "C" {
    EAPI int              ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, const char *filename, const char *user, const char *pass, const char *upload_dir);
    EAPI void             ecore_con_url_verbose_set(Ecore_Con_Url *url_con, int verbose);
    EAPI void             ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con, int use_epsv);
+   EAPI int               ecore_con_url_http_post_send(Ecore_Con_Url *url_con, void *curl_httppost);
 
 #ifdef __cplusplus
 }
index e1e7c85..ce106fa 100644 (file)
@@ -135,6 +135,7 @@ struct _Ecore_Con_Url
    ECORE_MAGIC;
    CURL              *curl_easy;
    struct curl_slist *headers;
+   struct curl_httppost* post;
    Eina_List         *additional_headers;
    Eina_List         *response_headers;
    char              *url;
index 436d823..9d11afb 100644 (file)
@@ -359,6 +359,11 @@ ecore_con_url_destroy(Ecore_Con_Url *url_con)
        url_con->fd = -1;
        url_con->fd_handler = NULL;
      }
+
+   if (url_con->post)
+     curl_formfree(url_con->post);
+   url_con->post = NULL;
+   
    if (url_con->curl_easy)
      {
        // FIXME: For an unknown reason, progress continue to arrive after destruction
@@ -823,6 +828,41 @@ ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, const char *filename, const cha
 }
 
 /**
+ * Send a Curl httppost 
+ * @return 1 on success, 0 on error.
+ * @ingroup Ecore_Con_Url_Group
+ */
+EAPI int
+ecore_con_url_http_post_send(Ecore_Con_Url *url_con, void *httppost)
+{
+#ifdef HAVE_CURL
+  int ret;
+
+  if (url_con->post)
+    curl_formfree(url_con->post);
+  url_con->post = NULL;
+
+  if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
+    {
+      ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_http_post_send");
+      return 0;
+    }
+
+  url_con->post = httppost;
+  
+  if (url_con->active) return 0;
+  if (!url_con->url) return 0;  
+  
+  curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPPOST, httppost);
+  
+  return ecore_con_url_send(url_con, NULL, 0, NULL);
+#else
+  return 0;
+  url_con = NULL;
+#endif
+}
+
+/**
  * Enable or disable libcurl verbose output, useful for debug
  * @return  FIXME: To be more documented.
  * @ingroup Ecore_Con_Url_Group