diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-07-13 09:58:28 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-07-14 17:53:45 +0200 |
commit | d75e3ab74c91eff67363cba064611d405105a12f (patch) | |
tree | f133a3f168915803e5a63ed44eadb0d6cad367d3 /lib/getinfo.c | |
parent | 8fa3f7809a30753a6c6bbedaf243de7447d018f3 (diff) | |
download | curl-d75e3ab74c91eff67363cba064611d405105a12f.tar.gz |
CURLINFO_EFFECTIVE_METHOD: added
Provide the HTTP method that was used on the latest request, which might
be relevant for users when there was one or more redirects involved.
Closes #5511
Diffstat (limited to 'lib/getinfo.c')
-rw-r--r-- | lib/getinfo.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/getinfo.c b/lib/getinfo.c index 6d5bd5fc5..675a616f0 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -95,6 +95,34 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info, case CURLINFO_EFFECTIVE_URL: *param_charp = data->change.url?data->change.url:(char *)""; break; + case CURLINFO_EFFECTIVE_METHOD: { + const char *m = data->set.str[STRING_CUSTOMREQUEST]; + if(!m) { + if(data->set.opt_no_body) + m = "HEAD"; + else { + switch(data->state.httpreq) { + case HTTPREQ_POST: + case HTTPREQ_POST_FORM: + case HTTPREQ_POST_MIME: + m = "POST"; + break; + case HTTPREQ_PUT: + m = "PUT"; + break; + default: /* this should never happen */ + case HTTPREQ_GET: + m = "GET"; + break; + case HTTPREQ_HEAD: + m = "HEAD"; + break; + } + } + } + *param_charp = m; + } + break; case CURLINFO_CONTENT_TYPE: *param_charp = data->info.contenttype; break; |