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