From a07b93ab492075f42e2ae4026289953d9cb86dc4 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 25 Oct 2010 02:53:06 +0000 Subject: [PATCH] From: Raphael Kubo da Costa This signature change follows libcurl's behaviour more closely: CURLOPT_POSTFIELDSIZE expects a long, and a value of -1 means that content length calculation is forwarded to libcurl, which performs a strlen() on CURLOPT_POSTFIELD. SVN revision: 53845 --- legacy/ecore/src/lib/ecore_con/Ecore_Con.h | 2 +- .../ecore/src/lib/ecore_con/ecore_con_url.c | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h index 11515de75e..d5fc0df19f 100644 --- a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h +++ b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h @@ -508,7 +508,7 @@ EAPI Eina_Bool ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *password, Eina_Bool safe); EAPI Eina_Bool ecore_con_url_send(Ecore_Con_Url *url_con, - const void *data, size_t length, + const void *data, long length, const char *content_type); EAPI void ecore_con_url_time(Ecore_Con_Url *url_con, Ecore_Con_Url_Time time_condition, diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con_url.c b/legacy/ecore/src/lib/ecore_con/ecore_con_url.c index 2ddbfada0c..d915966ca8 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con_url.c +++ b/legacy/ecore/src/lib/ecore_con/ecore_con_url.c @@ -786,13 +786,13 @@ ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, * * @param url_con Connection object to perform a request on, previously created * with ecore_con_url_new() or ecore_con_url_custom_new(). - * @param data Payload (data sent on the request) - * @param length Payload length + * @param data Payload (data sent on the request) + * @param length Payload length. If @c -1, rely on automatic length + * calculation via @c strlen() on @p data. * @param content_type Content type of the payload (e.g. text/xml) * * @return #EINA_TRUE on success, #EINA_FALSE on error. * - * * @see ecore_con_url_custom_new() * @see ecore_con_url_additional_headers_clear() * @see ecore_con_url_additional_header_add() @@ -802,7 +802,7 @@ ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, * @see ecore_con_url_time() */ EAPI Eina_Bool -ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, +ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, long length, const char *content_type) { #ifdef HAVE_CURL @@ -832,17 +832,14 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, if (data) { - curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDS, data); - curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDSIZE, length); - - if (content_type && (strlen(content_type) < 200)) + if ((content_type) && (strlen(content_type) < 200)) { - sprintf(tmp, "Content-type: %s", content_type); + snprintf(tmp, sizeof(tmp), "Content-Type: %s", content_type); url_con->headers = curl_slist_append(url_con->headers, tmp); } - sprintf(tmp, "Content-length: %zu", length); - url_con->headers = curl_slist_append(url_con->headers, tmp); + curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDS, data); + curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDSIZE, length); } switch (url_con->time_condition)