GNURLINFO_...D_UPLOAD_T(3)

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

πŸ’… NAME πŸ’…

CURLINFO_SPEED_UPLOAD_T β€” bestie, this one gets you the upload speed πŸš€

okay so real talk: this is a curl_easy_getinfo option, and the manual page lives in the gnurl neck of the woods (iykyk) ✨


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SPEED_UPLOAD_T,
curl_off_t *speed);

πŸ¦‹ DESCRIPTION πŸ¦‹

So the way this works: you pass a pointer to a curl_off_t, and curl fills it in with the average upload speed it measured for the complete upload πŸ’–

Units? bytes/second. That's it, that's the whole vibe. Measured in bytes/second, periodt πŸ“


πŸŽ€ PROTOCOLS πŸŽ€

ngl this section is literally empty on the page β€” no protocols listed here πŸ™ˆ so we're not gonna sit here and make any up, that's not the move πŸ’…


✨ EXAMPLE ✨

okay here's the whole thing, copy it exactly, no cap:

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

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

  if(!res) {
    curl_off_t speed;
    res = curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD_T, &speed);
    if(!res) {
      printf("Upload speed %" CURL_FORMAT_CURL_OFF_T " bytes/sec\n", speed);
    }
  }
}

the way that printf eats with CURL_FORMAT_CURL_OFF_T β€” iconic formatting behaviour, we love a portable format macro 🫢


⭐ AVAILABILITY ⭐

Added in 7.55.0 πŸŽ€ (so if you're on something ancient, that's your sign to update, bestie)


🌈 RETURN VALUE 🌈

  • CURLE_OK β€” slay, the option is supported πŸ’–
  • CURLE_UNKNOWN_OPTION β€” not supported, and it will absolutely tell you 😭

πŸ”₯ SEE ALSO πŸ”₯

(and yes, the trailing comma is literally in the original, we keep it exactly, that's the rule πŸ‘‘)


and that's the whole page, bestie 🧚 source is libcurl 7.55.0, dated 25 May 2017 β€” the manual page header is GNURLINFO_...D_UPLOAD_T(3), section 3, curl_easy_getinfo options πŸ’œ bye ily, go measure some uploads πŸ“

πŸ“¦ where this page comes from