GNURLOPT_TIMECONDITION(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

okay so bestie, welcome to the GNURLOPT_TIMECONDITION(3) page β€” yes, it comes from the curl_easy_setopt options manual, and we are absolutely treating it like main character energy. πŸ’… This is the little setopt that picks the condition for a time request, and it is lowkey iconic for conditional requests. ✨

πŸŽ€ NAME πŸŽ€

CURLOPT_TIMECONDITION β€” select condition for a time request. That's the whole assignment, and it ate. πŸ’–

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMECONDITION, long
       cond);

So you're calling curl_easy_setopt with a CURL *handle, the CURLOPT_TIMECONDITION option, and a long cond. Slay. 🫢

πŸ’… DESCRIPTION πŸ’…

You pass a long as the parameter, bestie. This defines how the CURLOPT_TIMEVALUE(3) time value is treated β€” like, it's the vibe check for that timestamp. You can set this parameter to CURL_TIMECOND_IFMODSINCE or CURL_TIMECOND_IFUNMODSINCE. Both valid, both in the group chat. 🌸

caveat time: the last modification time of a file is not always known, and in such instances this feature will have no effect even if the given time condition would not have been met. No cap, it just does nothing in that case. 😭

If you're nosy after a transfer, you can use curl_easy_getinfo(3) with the CURLINFO_CONDITION_UNMET option to learn if a zero-byte successful "transfer" was due to this condition not matching. That's your little detective moment. πŸ”₯

πŸ‘‘ DEFAULT πŸ‘‘

CURL_TIMECOND_NONE (0)

That's it. Zero condition, zero drama. πŸŽ€

🌈 PROTOCOLS 🌈

HTTP, FTP, RTSP, and FILE. Bestie, that's the lineup. ✨

πŸ¦‹ AVAILABILITY πŸ¦‹

Always. Like, always always. πŸ’œ

⭐ RETURN VALUE ⭐

Returns CURLE_OK. We love a clean success era. 🫢

πŸ“ SEE ALSO πŸ“

(Yes, with the comma. Copy it exactly, bestie.) πŸ’…

πŸ’– EXAMPLE πŸ’–

Okay, example time β€” this code is doing the absolute most in the best way:

       CURL *curl = curl_easy_init();
       if(curl) {
         curl_easy_setopt(curl, CURLOPT_URL, "http://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 */
         curl_easy_perform(curl);
       }

It sets the URL, sets CURLOPT_TIMEVALUE to 1577833200L (the comment says that's January 1, 2020, and we respect the comment), uses CURL_TIMECOND_IFMODSINCE, then performs the request. Periodt. πŸ’…


xoxo, your Unix bestie 🫢 β€” this page is libcurl 7.37.0 from 17 Jun 2014, and the footer is giving GNURLOPT_TIMECONDITION(3) energy. Bye bestie, go set some time conditions. πŸ’–βœ¨

πŸ“¦ where this page comes from