CURLOPT_REQUEST_TARGET.md (1607B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_REQUEST_TARGET 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_CUSTOMREQUEST (3) 9 - CURLOPT_HTTPGET (3) 10 - CURLOPT_PATH_AS_IS (3) 11 - CURLOPT_URL (3) 12 Protocol: 13 - HTTP 14 Added-in: 7.55.0 15 --- 16 17 # NAME 18 19 CURLOPT_REQUEST_TARGET - alternative target for this request 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REQUEST_TARGET, string); 27 ~~~ 28 29 # DESCRIPTION 30 31 Pass a char pointer to string which libcurl uses in the upcoming request 32 instead of the path as extracted from the URL. 33 34 libcurl passes on the verbatim string in its request without any filter or 35 other safe guards. That includes white space and control characters. 36 37 Using this option multiple times makes the last set string override the 38 previous ones. Set it to NULL to disable its use again. 39 40 The application does not have to keep the string around after setting this 41 option. 42 43 # DEFAULT 44 45 NULL 46 47 # %PROTOCOLS% 48 49 # EXAMPLE 50 51 ~~~c 52 int main(void) 53 { 54 CURL *curl = curl_easy_init(); 55 if(curl) { 56 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/*"); 57 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "OPTIONS"); 58 59 /* issue an OPTIONS * request (no leading slash) */ 60 curl_easy_setopt(curl, CURLOPT_REQUEST_TARGET, "*"); 61 62 /* Perform the request */ 63 curl_easy_perform(curl); 64 } 65 } 66 ~~~ 67 68 # %AVAILABILITY% 69 70 # RETURN VALUE 71 72 curl_easy_setopt(3) returns a CURLcode indicating success or error. 73 74 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 75 libcurl-errors(3).