• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_SCHEME
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_EFFECTIVE_URL (3)
9  - CURLINFO_PROTOCOL (3)
10  - CURLINFO_RESPONSE_CODE (3)
11  - curl_easy_getinfo (3)
12  - curl_easy_setopt (3)
13Protocol:
14  - All
15---
16
17# NAME
18
19CURLINFO_SCHEME - get the URL scheme (sometimes called protocol) used in the connection
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SCHEME, char **scheme);
27~~~
28
29# DESCRIPTION
30
31Pass a pointer to a char pointer to receive the pointer to a null-terminated
32string holding the URL scheme used for the most recent connection done with
33this CURL **handle**.
34
35The **scheme** pointer is NULL or points to private memory. You MUST NOT
36free - it gets freed when you call curl_easy_cleanup(3) on the corresponding
37CURL handle.
38
39The returned scheme might be upper or lowercase. Do comparisons case
40insensitively.
41
42# EXAMPLE
43
44~~~c
45int main(void)
46{
47  CURL *curl = curl_easy_init();
48  if(curl) {
49    CURLcode res;
50    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
51    res = curl_easy_perform(curl);
52    if(res == CURLE_OK) {
53      char *scheme = NULL;
54      curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
55      if(scheme)
56        printf("scheme: %s\n", scheme); /* scheme: HTTP */
57    }
58    curl_easy_cleanup(curl);
59  }
60}
61~~~
62
63# AVAILABILITY
64
65Added in 7.52.0
66
67# RETURN VALUE
68
69Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
70