CURLOPT_READDATA(3)

🌸 NAME 🌸

okay bestie, welcome to the CURLOPT_READDATA(3) page β€” it's from the Library Functions Manual, and it's literally about the pointer passed to the read callback. no cap, that's the whole vibe. πŸ’…

✨ SYNOPSIS ✨

       #include <curl/curl.h>

       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_READDATA, void *pointer);

πŸ’– DESCRIPTION πŸ’–

so here's the tea: this is the data pointer to pass to the file read function. if you use the CURLOPT_READFUNCTION(3) option, this is the pointer you get as input in the fourth argument to the callback. iykyk. 🫢

if you do not specify a read callback but instead rely on the default internal read function, this data must be a valid readable FILE * (cast to 'void *'). like, it has to actually be readable, bestie β€” no random pointer shenanigans. 😭

🚨 Windows DLL bestie alert: if you are using libcurl as a DLL on Windows, you must use the CURLOPT_READFUNCTION(3) callback if you set this option. otherwise you might experience crashes. and not the cute kind. πŸ’€

πŸŽ€ DEFAULT πŸŽ€

stdin β€” yes, the default is literally stdin. standard input main character energy. ✨

πŸ¦‹ PROTOCOLS πŸ¦‹

This functionality affects all supported protocols. all of them. periodt. 🌈

🌈 EXAMPLE 🌈

here's the example, untouched and iconic: πŸ‘‘

       struct MyData {
         void *custom;
       };

       int main(void)
       {
         CURL *curl = curl_easy_init();
         struct MyData this;
         if(curl) {
           curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");

           /* pass pointer that gets passed in to the
              CURLOPT_READFUNCTION callback */
           curl_easy_setopt(curl, CURLOPT_READDATA, &this);

           curl_easy_perform(curl);
         }
       }

πŸ’œ HISTORY πŸ’œ

This option was once known by the older name CURLOPT_INFILE; the name CURLOPT_READDATA(3) was introduced in 7.9.7. glow-up moment fr fr. ⭐

⭐ AVAILABILITY ⭐

Added in curl 7.9.7. πŸŽ€

πŸ”₯ RETURN VALUE πŸ”₯

This returns CURLE_OK. slay. βœ…

πŸ‘‘ SEE ALSO πŸ‘‘


mwah πŸ’– that's the whole page! this was the libcurl manual, dated 2026-10-12 β€” CURLOPT_READDATA(3) from the Library Functions Manual, signing off. 🫢🌸

πŸ“¦ where this page comes from