1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_EFFECTIVE_METHOD
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_CUSTOMREQUEST (3)
9  - CURLOPT_FOLLOWLOCATION (3)
10  - curl_easy_getinfo (3)
11  - curl_easy_setopt (3)
12Protocol:
13  - HTTP
14---
15
16# NAME
17
18CURLINFO_EFFECTIVE_METHOD - get the last used HTTP method
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_METHOD,
26                           char **methodp);
27~~~
28
29# DESCRIPTION
30
31Pass in a pointer to a char pointer and get the last used effective HTTP
32method.
33
34In cases when you have asked libcurl to follow redirects, the method may not be
35the same method the first request would use.
36
37The **methodp** pointer is NULL or points to private memory. You MUST NOT
38free - it gets freed when you call curl_easy_cleanup(3) on the
39corresponding CURL handle.
40
41# EXAMPLE
42
43~~~c
44int main(void)
45{
46  CURL *curl = curl_easy_init();
47  if(curl) {
48    CURLcode res;
49    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
50    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data");
51    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
52    res = curl_easy_perform(curl);
53    if(res == CURLE_OK) {
54      char *method = NULL;
55      curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_METHOD, &method);
56      if(method)
57        printf("Redirected to method: %s\n", method);
58    }
59    curl_easy_cleanup(curl);
60  }
61}
62~~~
63
64# AVAILABILITY
65
66Added in 7.72.0
67
68# RETURN VALUE
69
70Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
71