GNURLINFO_...ONNECTCODE(3)

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

πŸ’… GNURLINFO_...ONNECTCODE(3) πŸ’…

okay so bestie, welcome to the curl_easy_getinfo options corner of the manual πŸ’– this one is all about grabbing the response code from an HTTP proxy's CONNECT reply, and yes it is as niche as it sounds but also lowkey iconic ✨


🌸 NAME 🌸

CURLINFO_HTTP_CONNECTCODE β€” get the CONNECT response code πŸŽ€


✨ SYNOPSIS ✨

#include <gnurl/curl.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

bestie, you pass a pointer to a long and it receives the last received HTTP proxy response code to a CONNECT request. that's the whole vibe πŸ’…

and if no such response code was available? the returned value will be zero. no cap, that's just how it is 🫢


🌈 PROTOCOLS 🌈

HTTP


πŸŽ€ EXAMPLE πŸŽ€

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

  /* typically CONNECT is used to do HTTPS over HTTP proxies */
  curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1");
  res = curl_easy_perform(curl);
  if(res == CURLE_OK) {
    long code;
    res = curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE, &code);
    if(!res && code)
      printf("The CONNECT response code: %03ld\n", code);
  }
  curl_easy_cleanup(curl);
}

⭐ AVAILABILITY ⭐

Added in 7.10.7 ✨


πŸ’œ RETURN VALUE πŸ’œ

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. periodt πŸ’…


πŸ”₯ SEE ALSO πŸ”₯


bestie if you're messing with proxy CONNECT codes, this is your lil' main character function. go off πŸ‘‘πŸ’–

this iconic lil' page is brought to you by libcurl 7.44.0, dated 28 Aug 2015 πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from