GNURLINFO_FILETIME(3)

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

πŸ’… GNURLINFO_FILETIME(3) πŸ’…

hiii bestie!! welcome to GNURLINFO_FILETIME(3) β€” the page living its best life in the curl_easy_getinfo options manual. grab a strawberry πŸ“ and let's get into it.


✨ NAME ✨

  • CURLINFO_FILETIME β€” get the remote time of the retrieved document

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME, long *timep);

πŸ’… DESCRIPTION πŸ’…

okay so you pass a pointer to a long, and it receives the remote time of the retrieved document. that's the number of seconds since 1 jan 1970 in the GMT/UTC time zone, periodt. πŸ’–

if you get -1, it can be because of many reasons (it might be unknown, the server might hide it or the server doesn't support the command that tells document time etc) and the time of the document is unknown. not the vibe, but that's the deal.

bestie, you must tell libcurl to collect this information before the transfer is made, by using the CURLOPT_FILETIME(3) option to curl_easy_setopt(3) β€” or you will unconditionally get a -1 back. no cap. 🫢

also consider using CURLINFO_FILETIME_T(3) to be able to extract dates beyond the year 2038 on systems using 32 bit longs. future-proofing slay ✨

🌈 PROTOCOLS 🌈

HTTP(S), FTP(S), SFTP

πŸ“ EXAMPLE πŸ“

here's the example, literally untouched so you can copy it and go:

       curl = curl_easy_init();
       if(curl) {
         curl_easy_setopt(curl, CURLOPT_URL, url);
         /* Ask for filetime */
         curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
         res = curl_easy_perform(curl);
         if(CURLE_OK == res) {
           res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
           if((CURLE_OK == res) && (filetime >= 0)) {
             time_t file_time = (time_t)filetime;
             printf("filetime %s: %s", filename, ctime(&file_time));
           }
         }
         /* always cleanup */
         curl_easy_cleanup(curl);
       }

⭐ AVAILABILITY ⭐

Added in 7.5.

πŸŽ€ RETURN VALUE πŸŽ€

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.

πŸ’– SEE ALSO πŸ’–

mwah πŸ’‹ β€” this lil page is from libcurl 7.44.0, dated 28 Aug 2015, and yes bestie, it's GNURLINFO_FILETIME(3). bye 🫢

πŸ“¦ where this page comes from