1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_TIMECONDITION
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_FILETIME (3)
9  - CURLOPT_TIMEVALUE (3)
10---
11
12# NAME
13
14CURLOPT_TIMECONDITION - select condition for a time request
15
16# SYNOPSIS
17
18~~~c
19#include <curl/curl.h>
20
21CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMECONDITION, long cond);
22~~~
23
24# DESCRIPTION
25
26Pass a long as parameter. This defines how the CURLOPT_TIMEVALUE(3) time
27value is treated. You can set this parameter to *CURL_TIMECOND_IFMODSINCE*
28or *CURL_TIMECOND_IFUNMODSINCE*.
29
30The last modification time of a file is not always known and in such instances
31this feature has no effect even if the given time condition would not have
32been met. curl_easy_getinfo(3) with the *CURLINFO_CONDITION_UNMET*
33option can be used after a transfer to learn if a zero-byte successful
34"transfer" was due to this condition not matching.
35
36# DEFAULT
37
38CURL_TIMECOND_NONE (0)
39
40# PROTOCOLS
41
42HTTP, FTP, RTSP, and FILE
43
44# EXAMPLE
45
46~~~c
47int main(void)
48{
49  CURL *curl = curl_easy_init();
50  if(curl) {
51    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
52
53    /* January 1, 2020 is 1577833200 */
54    curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);
55
56    /* If-Modified-Since the above time stamp */
57    curl_easy_setopt(curl, CURLOPT_TIMECONDITION,
58                     (long)CURL_TIMECOND_IFMODSINCE);
59
60    /* Perform the request */
61    curl_easy_perform(curl);
62  }
63}
64~~~
65
66# AVAILABILITY
67
68Always
69
70# RETURN VALUE
71
72Returns CURLE_OK
73