From c8ef070623fd3c73dd61f333a4fb1dc4cdc314e2 Mon Sep 17 00:00:00 2001 From: jeffdameth Date: Thu, 6 May 2010 20:18:39 +0000 Subject: [PATCH] added fuction to send httposts created with curl formadd. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@48651 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_con/Ecore_Con.h | 1 + src/lib/ecore_con/ecore_con_private.h | 1 + src/lib/ecore_con/ecore_con_url.c | 40 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/lib/ecore_con/Ecore_Con.h b/src/lib/ecore_con/Ecore_Con.h index 7b66305..05efff0 100644 --- a/src/lib/ecore_con/Ecore_Con.h +++ b/src/lib/ecore_con/Ecore_Con.h @@ -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 } diff --git a/src/lib/ecore_con/ecore_con_private.h b/src/lib/ecore_con/ecore_con_private.h index e1e7c85..ce106fa 100644 --- a/src/lib/ecore_con/ecore_con_private.h +++ b/src/lib/ecore_con/ecore_con_private.h @@ -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; diff --git a/src/lib/ecore_con/ecore_con_url.c b/src/lib/ecore_con/ecore_con_url.c index 436d823..9d11afb 100644 --- a/src/lib/ecore_con/ecore_con_url.c +++ b/src/lib/ecore_con/ecore_con_url.c @@ -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 -- 2.7.4