added fuction to send httposts created with curl formadd.

SVN revision: 48651
This commit is contained in:
Hannes Janetzek 2010-05-06 20:18:39 +00:00
parent 1a49327928
commit 9dc6c78922
3 changed files with 42 additions and 0 deletions

View 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
}

View 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;

View 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
@ -822,6 +827,41 @@ ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, const char *filename, const cha
#endif
}
/**
* 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.