From: Raphael Kubo da Costa <kubo@profusion.mobi>
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 25 Oct 2010 02:53:06 +0000 (02:53 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 25 Oct 2010 02:53:06 +0000 (02:53 +0000)
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.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@53845 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

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

index 11515de..d5fc0df 100644 (file)
@@ -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,
index 2ddbfad..d915966 100644 (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
  *                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)