diff --git a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h index 2f6b0d1b46..11515de75e 100644 --- a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h +++ b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h @@ -462,14 +462,27 @@ EAPI void ecore_con_client_timeout_set(Ecore_Con_Client *cl, double /** * @typedef Ecore_Con_Url_Time * @enum _Ecore_Con_Url_Time - * The type of time in the object + * The type of condition to use when making an HTTP request dependent on time, + * so that headers such as "If-Modified-Since" are used. */ typedef enum _Ecore_Con_Url_Time { + /** + * Do not place time restrictions on the HTTP requests. + */ ECORE_CON_URL_TIME_NONE = 0, + /** + * Add the "If-Modified-Since" HTTP header, so that the request is performed + * by the server only if the target has been modified since the time value + * passed to it in the request. + */ ECORE_CON_URL_TIME_IFMODSINCE, - ECORE_CON_URL_TIME_IFUNMODSINCE, - ECORE_CON_URL_TIME_LASTMOD + /** + * Add the "If-Unmodified-Since" HTTP header, so that the request is + * performed by the server only if the target has NOT been modified since + * the time value passed to it in the request. + */ + ECORE_CON_URL_TIME_IFUNMODSINCE } Ecore_Con_Url_Time; EAPI int ecore_con_url_init(void); @@ -498,8 +511,8 @@ EAPI Eina_Bool ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, const char *content_type); EAPI void ecore_con_url_time(Ecore_Con_Url *url_con, - Ecore_Con_Url_Time condition, - time_t tm); + Ecore_Con_Url_Time time_condition, + double timestamp); EAPI Eina_Bool ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, const char *filename, diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con_private.h b/legacy/ecore/src/lib/ecore_con/ecore_con_private.h index 58d5da1ba0..5eaaf476fe 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con_private.h +++ b/legacy/ecore/src/lib/ecore_con/ecore_con_private.h @@ -168,8 +168,8 @@ struct _Ecore_Con_Url Eina_List *response_headers; char *url; - Ecore_Con_Url_Time condition; - time_t time; + Ecore_Con_Url_Time time_condition; + double timestamp; void *data; Ecore_Fd_Handler *fd_handler; 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 f97ff08c06..2ddbfada0c 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con_url.c +++ b/legacy/ecore/src/lib/ecore_con/ecore_con_url.c @@ -615,12 +615,18 @@ ecore_con_url_data_get(Ecore_Con_Url *url_con) } /** - * FIXME - * Sets the @ref Ecore_Con_Url object's condition/time members. + * Sets whether HTTP requests should be conditional, dependent on + * modification time. + * + * @param url_con Ecore_Con_Url to act upon. + * @param condition Condition to use for HTTP requests. + * @param timestamp Time since 1 Jan 1970 to use in the condition. + * + * @sa ecore_con_url_send() */ EAPI void ecore_con_url_time(Ecore_Con_Url *url_con, Ecore_Con_Url_Time condition, - time_t tm) + double timestamp) { #ifdef HAVE_CURL if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) @@ -629,13 +635,13 @@ ecore_con_url_time(Ecore_Con_Url *url_con, Ecore_Con_Url_Time condition, return; } - url_con->condition = condition; - url_con->time = tm; + url_con->time_condition = condition; + url_con->timestamp = timestamp; #else return; - url_con = NULL; - condition = 0; - tm = 0; + (void)url_con; + (void)condition; + (void)timestamp; #endif } @@ -793,6 +799,7 @@ ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, * @see ecore_con_url_data_set() * @see ecore_con_url_data_get() * @see ecore_con_url_response_headers_get() + * @see ecore_con_url_time() */ EAPI Eina_Bool ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, @@ -838,7 +845,7 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, url_con->headers = curl_slist_append(url_con->headers, tmp); } - switch (url_con->condition) + switch (url_con->time_condition) { case ECORE_CON_URL_TIME_NONE: curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, @@ -848,19 +855,15 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, case ECORE_CON_URL_TIME_IFMODSINCE: curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE); - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, url_con->time); + curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, + (long)url_con->timestamp); break; case ECORE_CON_URL_TIME_IFUNMODSINCE: curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFUNMODSINCE); - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, url_con->time); - break; - - case ECORE_CON_URL_TIME_LASTMOD: - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, - CURL_TIMECOND_LASTMOD); - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, url_con->time); + curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, + (long)url_con->timestamp); break; }