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
14Added-in: 7.55.0
15---
16
17# NAME
18
19CURLOPT_REQUEST_TARGET - alternative target for this request
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REQUEST_TARGET, string);
27~~~
28
29# DESCRIPTION
30
31Pass a char pointer to string which libcurl uses in the upcoming request
32instead of the path as extracted from the URL.
33
34libcurl passes on the verbatim string in its request without any filter or
35other safe guards. That includes white space and control characters.
36
37Using this option multiple times makes the last set string override the
38previous ones. Set it to NULL to disable its use again.
39
40The application does not have to keep the string around after setting this
41option.
42
43# DEFAULT
44
45NULL
46
47# %PROTOCOLS%
48
49# EXAMPLE
50
51~~~c
52int 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
72Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
73