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