CURLOPT_CURLU.md (1619B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_CURLU 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_URL (3) 9 - curl_url (3) 10 - curl_url_cleanup (3) 11 - curl_url_dup (3) 12 - curl_url_get (3) 13 - curl_url_set (3) 14 - curl_url_strerror (3) 15 Protocol: 16 - All 17 Added-in: 7.63.0 18 --- 19 20 # NAME 21 22 CURLOPT_CURLU - URL in URL handle format 23 24 # SYNOPSIS 25 26 ~~~c 27 #include <curl/curl.h> 28 29 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CURLU, CURLU *pointer); 30 ~~~ 31 32 # DESCRIPTION 33 34 Pass in a pointer to the *URL* handle to work with. The parameter should be a 35 *CURLU pointer*. Setting CURLOPT_CURLU(3) explicitly overrides 36 CURLOPT_URL(3). 37 38 CURLOPT_URL(3) or CURLOPT_CURLU(3) **must** be set before a 39 transfer is started. 40 41 libcurl uses this handle and its contents read-only and does not change its 42 contents. An application can update the contents of the URL handle after a 43 transfer is done and if the same handle is used in a subsequent request the 44 updated contents is used. 45 46 # DEFAULT 47 48 NULL 49 50 # %PROTOCOLS% 51 52 # EXAMPLE 53 54 ~~~c 55 int main(void) 56 { 57 CURL *curl = curl_easy_init(); 58 CURLU *urlp = curl_url(); 59 if(curl) { 60 CURLcode res; 61 CURLUcode ret; 62 ret = curl_url_set(urlp, CURLUPART_URL, "https://example.com", 0); 63 64 curl_easy_setopt(curl, CURLOPT_CURLU, urlp); 65 66 res = curl_easy_perform(curl); 67 68 curl_url_cleanup(urlp); 69 curl_easy_cleanup(curl); 70 } 71 } 72 ~~~ 73 74 # %AVAILABILITY% 75 76 # RETURN VALUE 77 78 curl_easy_setopt(3) returns a CURLcode indicating success or error. 79 80 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 81 libcurl-errors(3).