xref: /curl/docs/libcurl/opts/CURLINFO_PROTOCOL.md (revision 3040971d)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_PROTOCOL
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_RESPONSE_CODE (3)
9  - curl_easy_getinfo (3)
10  - curl_easy_setopt (3)
11Protocol:
12  - All
13Added-in: 7.52.0
14---
15
16# NAME
17
18CURLINFO_PROTOCOL - get the protocol used in the connection
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROTOCOL, long *p);
26~~~
27
28# DESCRIPTION
29
30This option is deprecated. We strongly recommend using
31CURLINFO_SCHEME(3) instead, because this option cannot return all
32possible protocols.
33
34Pass a pointer to a long to receive the version used in the last http
35connection. The returned value is set to one of the CURLPROTO_* values:
36
37~~~c
38CURLPROTO_DICT, CURLPROTO_FILE, CURLPROTO_FTP, CURLPROTO_FTPS,
39CURLPROTO_GOPHER, CURLPROTO_HTTP, CURLPROTO_HTTPS, CURLPROTO_IMAP,
40CURLPROTO_IMAPS, CURLPROTO_LDAP, CURLPROTO_LDAPS, CURLPROTO_POP3,
41CURLPROTO_POP3S, CURLPROTO_RTMP, CURLPROTO_RTMPE, CURLPROTO_RTMPS,
42CURLPROTO_RTMPT, CURLPROTO_RTMPTE, CURLPROTO_RTMPTS, CURLPROTO_RTSP,
43CURLPROTO_SCP, CURLPROTO_SFTP, CURLPROTO_SMB, CURLPROTO_SMBS, CURLPROTO_SMTP,
44CURLPROTO_SMTPS, CURLPROTO_TELNET, CURLPROTO_TFTP, CURLPROTO_MQTT
45~~~
46
47# %PROTOCOLS%
48
49# EXAMPLE
50
51~~~c
52int main(void)
53{
54  CURL *curl = curl_easy_init();
55  if(curl) {
56    CURLcode res;
57    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
58    res = curl_easy_perform(curl);
59    if(res == CURLE_OK) {
60      long protocol;
61      curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
62    }
63    curl_easy_cleanup(curl);
64  }
65}
66~~~
67
68# DEPRECATED
69
70Deprecated since 7.85.0.
71
72# %AVAILABILITY%
73
74# RETURN VALUE
75
76Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
77