summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-02-09 21:23:32 +0100
committerBoris Faure <billiob@gmail.com>2015-02-19 22:52:50 +0100
commit3a7b9a86cfff3a42f3df9883d18ef949fbd81899 (patch)
tree63687b0f4665fac62c71a75e911944f4a4fe1f69 /src/lib/ecore_con
parentb64c77004638221724189fef53369e14101326dd (diff)
ecore_con_url: add ecore_con_url_head()
Just like ecore_con_url_get() or ecore_con_url_post() but to a HTTP HEAD. @feature
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/Ecore_Con.h20
-rw-r--r--src/lib/ecore_con/ecore_con_url.c14
2 files changed, 32 insertions, 2 deletions
diff --git a/src/lib/ecore_con/Ecore_Con.h b/src/lib/ecore_con/Ecore_Con.h
index 41a1e90b2f..9ade8379ca 100644
--- a/src/lib/ecore_con/Ecore_Con.h
+++ b/src/lib/ecore_con/Ecore_Con.h
@@ -1555,6 +1555,26 @@ EAPI Eina_Bool ecore_con_url_httpauth_set(Ecore_Con_Url *url_con,
1555 */ 1555 */
1556EAPI Eina_Bool ecore_con_url_get(Ecore_Con_Url *url_con); 1556EAPI Eina_Bool ecore_con_url_get(Ecore_Con_Url *url_con);
1557/** 1557/**
1558 * Sends a HEAD request.
1559 *
1560 * @param url_con Connection object to perform a request on, previously created
1561 *
1562 * @return @c EINA_TRUE on success, @c EINA_FALSE on error.
1563 *
1564 * The request is performed immediately, but you need to setup event handlers
1565 * for #ECORE_CON_EVENT_URL_COMPLETE or #ECORE_CON_EVENT_URL_PROGRESS to get
1566 * more information about its result.
1567 *
1568 * @see ecore_con_url_custom_new()
1569 * @see ecore_con_url_additional_headers_clear()
1570 * @see ecore_con_url_additional_header_add()
1571 * @see ecore_con_url_response_headers_get()
1572 * @see ecore_con_url_time()
1573 * @see ecore_con_url_post()
1574 * @since 1.14
1575 */
1576EAPI Eina_Bool ecore_con_url_head(Ecore_Con_Url *url_con);
1577/**
1558 * Sends a post request. 1578 * Sends a post request.
1559 * 1579 *
1560 * @param url_con Connection object to perform a request on, previously created 1580 * @param url_con Connection object to perform a request on, previously created
diff --git a/src/lib/ecore_con/ecore_con_url.c b/src/lib/ecore_con/ecore_con_url.c
index 22c2a97b1a..18fd566e56 100644
--- a/src/lib/ecore_con/ecore_con_url.c
+++ b/src/lib/ecore_con/ecore_con_url.c
@@ -32,9 +32,9 @@
32 32
33#define MY_CLASS ECORE_CON_URL_CLASS 33#define MY_CLASS ECORE_CON_URL_CLASS
34 34
35// all the types, defines, enums etc. from curl that we actuall USE. 35// all the types, defines, enums etc. from curl that we actually USE.
36// we have to add to this if we use more things from curl not already 36// we have to add to this if we use more things from curl not already
37// defined here. see culr headers to get them from 37// defined here. see curl headers to get them from
38typedef enum 38typedef enum
39{ 39{
40 CURLM_CALL_MULTI_PERFORM = -1, 40 CURLM_CALL_MULTI_PERFORM = -1,
@@ -68,6 +68,7 @@ typedef enum
68 CINIT(CUSTOMREQUEST, OBJECTPOINT, 36), 68 CINIT(CUSTOMREQUEST, OBJECTPOINT, 36),
69 CINIT(VERBOSE, LONG, 41), 69 CINIT(VERBOSE, LONG, 41),
70 CINIT(NOPROGRESS, LONG, 43), 70 CINIT(NOPROGRESS, LONG, 43),
71 CINIT(NOBODY, LONG, 44),
71 CINIT(UPLOAD, LONG, 46), 72 CINIT(UPLOAD, LONG, 46),
72 CINIT(POST, LONG, 47), 73 CINIT(POST, LONG, 47),
73 CINIT(FOLLOWLOCATION, LONG, 52), 74 CINIT(FOLLOWLOCATION, LONG, 52),
@@ -188,6 +189,7 @@ typedef enum _Ecore_Con_Url_Mode
188 ECORE_CON_URL_MODE_AUTO = 0, 189 ECORE_CON_URL_MODE_AUTO = 0,
189 ECORE_CON_URL_MODE_GET = 1, 190 ECORE_CON_URL_MODE_GET = 1,
190 ECORE_CON_URL_MODE_POST = 2, 191 ECORE_CON_URL_MODE_POST = 2,
192 ECORE_CON_URL_MODE_HEAD = 3,
191} Ecore_Con_Url_Mode; 193} Ecore_Con_Url_Mode;
192 194
193typedef struct _Ecore_Con_Curl Ecore_Con_Curl; 195typedef struct _Ecore_Con_Curl Ecore_Con_Curl;
@@ -846,6 +848,8 @@ _ecore_con_url_send(Ecore_Con_Url *url_obj, Ecore_Con_Url_Mode mode,
846 if (mode == ECORE_CON_URL_MODE_POST) 848 if (mode == ECORE_CON_URL_MODE_POST)
847 _c->curl_easy_setopt(url_con->curl_easy, CURLOPT_POST, 1); 849 _c->curl_easy_setopt(url_con->curl_easy, CURLOPT_POST, 1);
848 } 850 }
851 else if (mode == ECORE_CON_URL_MODE_HEAD)
852 _c->curl_easy_setopt(url_con->curl_easy, CURLOPT_NOBODY, 1L);
849 853
850 switch (url_con->time_condition) 854 switch (url_con->time_condition)
851 { 855 {
@@ -885,6 +889,12 @@ ecore_con_url_get(Ecore_Con_Url *url_con)
885} 889}
886 890
887EAPI Eina_Bool 891EAPI Eina_Bool
892ecore_con_url_head(Ecore_Con_Url *url_con)
893{
894 return _ecore_con_url_send(url_con, ECORE_CON_URL_MODE_HEAD, NULL, 0, NULL);
895}
896
897EAPI Eina_Bool
888ecore_con_url_post(Ecore_Con_Url *url_con, const void *data, long length, const char *content_type) 898ecore_con_url_post(Ecore_Con_Url *url_con, const void *data, long length, const char *content_type)
889{ 899{
890 return _ecore_con_url_send(url_con, ECORE_CON_URL_MODE_POST, data, length, content_type); 900 return _ecore_con_url_send(url_con, ECORE_CON_URL_MODE_POST, data, length, content_type);