CURLINFO_HTTP_VERSION(3)

πŸ’– CURLINFO_HTTP_VERSION(3) πŸ’–

Okay bestie, welcome to the Library Functions Manual corner πŸ’… this is the whole vibe for CURLINFO_HTTP_VERSION β€” the HTTP version used in the transfer. No cap, it's giving β€œwhich HTTP flavor did we just speak?” energy ✨


🌸 NAME 🌸

CURLINFO_HTTP_VERSION β€” HTTP version used in the transfer πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTP_VERSION, long *p);

✨ DESCRIPTION ✨

Pass a pointer to a long to receive the version used in the last http transfer done using this handle. The returned value is CURL_HTTP_VERSION_1_0, CURL_HTTP_VERSION_1_1, CURL_HTTP_VERSION_2_0, CURL_HTTP_VERSION_3 or 0 if the version cannot be determined.

Like, you hand it a long *p and it fills your little long with the version info πŸ’– β€” unless it literally cannot figure it out, in which case you get 0. That's the whole deal, periodt.


πŸ¦‹ PROTOCOLS πŸ¦‹

This functionality affects http only.


πŸ”₯ EXAMPLE πŸ”₯

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    result = curl_easy_perform(curl);
    if(result == CURLE_OK) {
      long http_version;
      curl_easy_getinfo(curl, CURLINFO_HTTP_VERSION, &http_version);
    }
    curl_easy_cleanup(curl);
  }
}

⭐ AVAILABILITY ⭐

Added in curl 7.50.0 🫢


πŸ‘‘ RETURN VALUE πŸ‘‘

curl_easy_getinfo(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3) 😭


🌈 SEE ALSO 🌈


That's the tea, bestie πŸ“ this page is from libcurl, dated 2026-10-12, and it's literally CURLINFO_HTTP_VERSION(3) πŸ’œβœ¨

πŸ“¦ where this page comes from