1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_CONDITION_UNMET
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_TIMECONDITION (3)
9  - CURLOPT_TIMEVALUE (3)
10  - curl_easy_getinfo (3)
11  - curl_easy_setopt (3)
12Protocol:
13  - HTTP
14Added-in: 7.19.4
15---
16
17# NAME
18
19CURLINFO_CONDITION_UNMET - get info on unmet time conditional or 304 HTTP response.
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONDITION_UNMET,
27                           long *unmet);
28~~~
29
30# DESCRIPTION
31
32Pass a pointer to a long to receive the number 1 if the condition provided in
33the previous request did not match (see CURLOPT_TIMECONDITION(3)). Alas,
34if this returns a 1 you know that the reason you did not get data in return is
35because it did not fulfill the condition. The long this argument points to
36gets a zero stored if the condition instead was met. This can also return 1 if
37the server responded with a 304 HTTP status code, for example after sending a
38custom "If-Match-*" header.
39
40# %PROTOCOLS%
41
42# EXAMPLE
43
44~~~c
45int main(void)
46{
47  CURL *curl = curl_easy_init();
48  if(curl) {
49    CURLcode res;
50
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    res = curl_easy_perform(curl);
62
63    if(!res) {
64      /* check the time condition */
65      long unmet;
66      res = curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
67      if(!res) {
68        printf("The time condition was %sfulfilled\n", unmet?"NOT":"");
69      }
70    }
71  }
72}
73~~~
74
75# %AVAILABILITY%
76
77# RETURN VALUE
78
79Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
80