CURLINFO_CONDITION_UNMET(3)

πŸ’… CURLINFO_CONDITION_UNMET(3) β€” Library Functions Manual

ok so bestie, we're looking at CURLINFO_CONDITION_UNMET today, and it's genuinely one of those little info-grabbers that eats. it lives over in the curl_easy_getinfo fam, iykyk πŸŽ€


✨ NAME ✨

CURLINFO_CONDITION_UNMET β€” the "unmet time conditional or 304 HTTP response" vibe check 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONDITION_UNMET,
                           long *unmet);

πŸ’– DESCRIPTION πŸ’–

okay so the move here is: you pass a pointer to a long, and that long gets the number 1 dropped into it if the condition you set up in the previous request did not match β€” see CURLOPT_TIMECONDITION(3) for the receipts πŸ’…

and like, the way that this is actually useful? if this returns a 1, you know the reason you didn't get any data back is that your condition wasn't fulfilled. no mystery, no ghosting, the condition just said no 😭

the long that this argument points to gets a zero stored instead if the condition was met. slay.

also β€” and this is the part people forget β€” this can also return 1 if the server responded with a 304 HTTP status code, for example after you sent a custom "If-Match-*" header. so it's doing double duty, main character energy fr fr πŸ‘‘


🌈 PROTOCOLS 🌈

this functionality affects http only. that's it, that's the whole list 🫢


πŸ“ EXAMPLE πŸ“

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;

    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");

    /* January 1, 2020 is 1577833200 */
    curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);

    /* If-Modified-Since the above time stamp */
    curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);

    /* Perform the request */
    result = curl_easy_perform(curl);

    if(!result) {
      /* check the time condition */
      long unmet;
      result = curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
      if(!result) {
        printf("The time condition was %sfulfilled\n", unmet?"NOT":"");
      }
    }
  }
}

like, look at her go 🧚 she sets a URL, sets CURLOPT_TIMEVALUE to 1577833200L (that's January 1, 2020, the comment literally says so), asks for CURL_TIMECOND_IFMODSINCE, performs the request, and then checks CURLINFO_CONDITION_UNMET to see what happened. and the printf there does that cute little trick where unmet?"NOT":"" slots right into "%sfulfilled" β€” so you get either fulfilled or NOTfulfilled. iconic string surgery πŸ’…βœ¨


⭐ AVAILABILITY ⭐

Added in curl 7.19.4 β€” so she's been around a minute, respect the elders πŸ‘‘


πŸ’œ RETURN VALUE πŸ’œ

curl_easy_getinfo(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK. non-zero means an error occurred β€” go peek at libcurl-errors(3) for the full tea πŸ’€


πŸ”₯ SEE ALSO πŸ”₯


ok that's the whole page, no notes 🌸 this has been libcurl, dated 2026-10-12, and your girl CURLINFO_CONDITION_UNMET(3) is signing off β€” mwah, go check your time conditions, ily πŸ«ΆπŸ’–πŸŽ€

πŸ“¦ where this page comes from