From: Raphael Kubo da Costa <kubo@profusion.mobi>

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
This commit is contained in:
Raphael Kubo da Costa 2010-10-25 02:53:06 +00:00 committed by Carsten Haitzler
parent 57b70bdb14
commit a07b93ab49
2 changed files with 9 additions and 12 deletions

View File

@ -508,7 +508,7 @@ EAPI Eina_Bool ecore_con_url_httpauth_set(Ecore_Con_Url *url_con,
const char *password, const char *password,
Eina_Bool safe); Eina_Bool safe);
EAPI Eina_Bool ecore_con_url_send(Ecore_Con_Url *url_con, 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); const char *content_type);
EAPI void ecore_con_url_time(Ecore_Con_Url *url_con, EAPI void ecore_con_url_time(Ecore_Con_Url *url_con,
Ecore_Con_Url_Time time_condition, Ecore_Con_Url_Time time_condition,

View File

@ -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 * @param url_con Connection object to perform a request on, previously created
* with ecore_con_url_new() or ecore_con_url_custom_new(). * with ecore_con_url_new() or ecore_con_url_custom_new().
* @param data Payload (data sent on the request) * @param data Payload (data sent on the request)
* @param length Payload length * @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) * @param content_type Content type of the payload (e.g. text/xml)
* *
* @return #EINA_TRUE on success, #EINA_FALSE on error. * @return #EINA_TRUE on success, #EINA_FALSE on error.
* *
*
* @see ecore_con_url_custom_new() * @see ecore_con_url_custom_new()
* @see ecore_con_url_additional_headers_clear() * @see ecore_con_url_additional_headers_clear()
* @see ecore_con_url_additional_header_add() * @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() * @see ecore_con_url_time()
*/ */
EAPI Eina_Bool 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) const char *content_type)
{ {
#ifdef HAVE_CURL #ifdef HAVE_CURL
@ -832,17 +832,14 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length,
if (data) if (data)
{ {
curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDS, data); if ((content_type) && (strlen(content_type) < 200))
curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDSIZE, length);
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); url_con->headers = curl_slist_append(url_con->headers, tmp);
} }
sprintf(tmp, "Content-length: %zu", length); curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDS, data);
url_con->headers = curl_slist_append(url_con->headers, tmp); curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDSIZE, length);
} }
switch (url_con->time_condition) switch (url_con->time_condition)