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