CURLINFO_CONDITION_UNMET.md (2016B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLINFO_CONDITION_UNMET 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_TIMECONDITION (3) 9 - CURLOPT_TIMEVALUE (3) 10 - curl_easy_getinfo (3) 11 - curl_easy_setopt (3) 12 Protocol: 13 - HTTP 14 Added-in: 7.19.4 15 --- 16 17 # NAME 18 19 CURLINFO_CONDITION_UNMET - get info on unmet time conditional or 304 HTTP response. 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONDITION_UNMET, 27 long *unmet); 28 ~~~ 29 30 # DESCRIPTION 31 32 Pass a pointer to a long to receive the number 1 if the condition provided in 33 the previous request did not match (see CURLOPT_TIMECONDITION(3)). Alas, 34 if this returns a 1 you know that the reason you did not get data in return is 35 because it did not fulfill the condition. The long this argument points to 36 gets a zero stored if the condition instead was met. This can also return 1 if 37 the server responded with a 304 HTTP status code, for example after sending a 38 custom "If-Match-*" header. 39 40 # %PROTOCOLS% 41 42 # EXAMPLE 43 44 ~~~c 45 int 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 79 curl_easy_getinfo(3) returns a CURLcode indicating success or error. 80 81 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 82 libcurl-errors(3).