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