CURLINFO_SCHEME.3 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. .\" generated by cd2nroff 0.1 from CURLINFO_SCHEME.md
  2. .TH CURLINFO_SCHEME 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_SCHEME \- get the URL scheme (sometimes called protocol) used in the connection
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SCHEME, char **scheme);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a pointer to a char pointer to receive the pointer to a null\-terminated
  12. string holding the URL scheme used for the most recent connection done with
  13. this CURL \fBhandle\fP.
  14. The \fBscheme\fP pointer is NULL or points to private memory. You MUST NOT
  15. free \- it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the corresponding
  16. CURL handle.
  17. The returned scheme might be upper or lowercase. Do comparisons case
  18. insensitively.
  19. .SH PROTOCOLS
  20. This functionality affects all supported protocols
  21. .SH EXAMPLE
  22. .nf
  23. int main(void)
  24. {
  25. CURL *curl = curl_easy_init();
  26. if(curl) {
  27. CURLcode res;
  28. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  29. res = curl_easy_perform(curl);
  30. if(res == CURLE_OK) {
  31. char *scheme = NULL;
  32. curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
  33. if(scheme)
  34. printf("scheme: %s\\n", scheme); /* scheme: HTTP */
  35. }
  36. curl_easy_cleanup(curl);
  37. }
  38. }
  39. .fi
  40. .SH AVAILABILITY
  41. Added in curl 7.52.0
  42. .SH RETURN VALUE
  43. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  44. .SH SEE ALSO
  45. .BR CURLINFO_EFFECTIVE_URL (3),
  46. .BR CURLINFO_PROTOCOL (3),
  47. .BR CURLINFO_RESPONSE_CODE (3),
  48. .BR curl_easy_getinfo (3),
  49. .BR curl_easy_setopt (3)