1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_REQUEST_TARGET
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_CUSTOMREQUEST (3)
9  - CURLOPT_HTTPGET (3)
10  - CURLOPT_PATH_AS_IS (3)
11  - CURLOPT_URL (3)
12Protocol:
13  - HTTP
14---
15
16# NAME
17
18CURLOPT_REQUEST_TARGET - alternative target for this request
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REQUEST_TARGET, string);
26~~~
27
28# DESCRIPTION
29
30Pass a char pointer to string which libcurl uses in the upcoming request
31instead of the path as extracted from the URL.
32
33libcurl passes on the verbatim string in its request without any filter or
34other safe guards. That includes white space and control characters.
35
36# DEFAULT
37
38NULL
39
40# EXAMPLE
41
42~~~c
43int main(void)
44{
45  CURL *curl = curl_easy_init();
46  if(curl) {
47    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/*");
48    curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
49
50    /* issue an OPTIONS * request (no leading slash) */
51    curl_easy_setopt(curl, CURLOPT_REQUEST_TARGET, "*");
52
53    /* Perform the request */
54    curl_easy_perform(curl);
55  }
56}
57~~~
58
59# AVAILABILITY
60
61Added in 7.55.0
62
63# RETURN VALUE
64
65Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
66