CURLINFO_EFFECTIVE_METHOD.3 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .\" generated by cd2nroff 0.1 from CURLINFO_EFFECTIVE_METHOD.md
  2. .TH CURLINFO_EFFECTIVE_METHOD 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_EFFECTIVE_METHOD \- get the last used HTTP method
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_METHOD,
  9. char **methodp);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass in a pointer to a char pointer and get the last used effective HTTP
  13. method.
  14. In cases when you have asked libcurl to follow redirects, the method may not be
  15. the same method the first request would use.
  16. The \fBmethodp\fP pointer is NULL or points to private memory. You MUST NOT
  17. free \- it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the
  18. corresponding CURL handle.
  19. .SH PROTOCOLS
  20. This functionality affects http only
  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. curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data");
  30. curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  31. res = curl_easy_perform(curl);
  32. if(res == CURLE_OK) {
  33. char *method = NULL;
  34. curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_METHOD, &method);
  35. if(method)
  36. printf("Redirected to method: %s\\n", method);
  37. }
  38. curl_easy_cleanup(curl);
  39. }
  40. }
  41. .fi
  42. .SH AVAILABILITY
  43. Added in curl 7.72.0
  44. .SH RETURN VALUE
  45. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  46. .SH SEE ALSO
  47. .BR CURLOPT_CUSTOMREQUEST (3),
  48. .BR CURLOPT_FOLLOWLOCATION (3),
  49. .BR curl_easy_getinfo (3),
  50. .BR curl_easy_setopt (3)