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
This commit is contained in:
Boris Faure 2015-02-09 21:23:32 +01:00
parent b64c770046
commit 3a7b9a86cf
2 changed files with 32 additions and 2 deletions

View File

@ -1554,6 +1554,26 @@ EAPI Eina_Bool ecore_con_url_httpauth_set(Ecore_Con_Url *url_con,
* @see ecore_con_url_post()
*/
EAPI Eina_Bool ecore_con_url_get(Ecore_Con_Url *url_con);
/**
* Sends a HEAD request.
*
* @param url_con Connection object to perform a request on, previously created
*
* @return @c EINA_TRUE on success, @c EINA_FALSE on error.
*
* The request is performed immediately, but you need to setup event handlers
* for #ECORE_CON_EVENT_URL_COMPLETE or #ECORE_CON_EVENT_URL_PROGRESS to get
* more information about its result.
*
* @see ecore_con_url_custom_new()
* @see ecore_con_url_additional_headers_clear()
* @see ecore_con_url_additional_header_add()
* @see ecore_con_url_response_headers_get()
* @see ecore_con_url_time()
* @see ecore_con_url_post()
* @since 1.14
*/
EAPI Eina_Bool ecore_con_url_head(Ecore_Con_Url *url_con);
/**
* Sends a post request.
*

View File

@ -32,9 +32,9 @@
#define MY_CLASS ECORE_CON_URL_CLASS
// all the types, defines, enums etc. from curl that we actuall USE.
// all the types, defines, enums etc. from curl that we actually USE.
// we have to add to this if we use more things from curl not already
// defined here. see culr headers to get them from
// defined here. see curl headers to get them from
typedef enum
{
CURLM_CALL_MULTI_PERFORM = -1,
@ -68,6 +68,7 @@ typedef enum
CINIT(CUSTOMREQUEST, OBJECTPOINT, 36),
CINIT(VERBOSE, LONG, 41),
CINIT(NOPROGRESS, LONG, 43),
CINIT(NOBODY, LONG, 44),
CINIT(UPLOAD, LONG, 46),
CINIT(POST, LONG, 47),
CINIT(FOLLOWLOCATION, LONG, 52),
@ -188,6 +189,7 @@ typedef enum _Ecore_Con_Url_Mode
ECORE_CON_URL_MODE_AUTO = 0,
ECORE_CON_URL_MODE_GET = 1,
ECORE_CON_URL_MODE_POST = 2,
ECORE_CON_URL_MODE_HEAD = 3,
} Ecore_Con_Url_Mode;
typedef 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,
if (mode == ECORE_CON_URL_MODE_POST)
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_POST, 1);
}
else if (mode == ECORE_CON_URL_MODE_HEAD)
_c->curl_easy_setopt(url_con->curl_easy, CURLOPT_NOBODY, 1L);
switch (url_con->time_condition)
{
@ -884,6 +888,12 @@ ecore_con_url_get(Ecore_Con_Url *url_con)
return _ecore_con_url_send(url_con, ECORE_CON_URL_MODE_GET, NULL, 0, NULL);
}
EAPI Eina_Bool
ecore_con_url_head(Ecore_Con_Url *url_con)
{
return _ecore_con_url_send(url_con, ECORE_CON_URL_MODE_HEAD, NULL, 0, NULL);
}
EAPI Eina_Bool
ecore_con_url_post(Ecore_Con_Url *url_con, const void *data, long length, const char *content_type)
{