Until curl 8.6.0, it was possible to obtain Content-Length using CURLINFO_CONTENT_LENGTH_DOWNLOAD_T in the header callback, but after https://github.com/curl/curl/pull/13134 was committed, it now returns -1.
According to the API documentation for curl_easy_getinfo(), "Use this function after a performed transfer if you want to get transfer related data.", so it may just have been possible to retrieve the data by chance up until now, but is the above behavior by design? Sudo code: ``` static size_t header_callback(char *buffer, size_t size, size_t nitems, void *userdata) { CURL *curl = userdata; CURLcode res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl); if(!res) { printf("Download size: %" CURL_FORMAT_CURL_OFF_T "\n", cl); } return nitems * size; } int main(void) { CURL *curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback); curl_easy_setopt(curl, CURLOPT_HEADERDATA, curl); curl_easy_perform(curl); } } ``` -- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.html