CURLOPT_REQUEST_TARGET(3)

CURLOPT_REQUEST_TARGET3

Alternative target for this request

Usage

#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REQUEST_TARGET, string);

Overview

Pass a char pointer to string which libcurl uses in the upcoming request instead of the path as extracted from the URL.

libcurl passes on the verbatim string in its request without any filter or other safe guards. That includes white space and control characters.

Using this option multiple times makes the last set string override the previous ones. Set it to NULL to disable its use again.

The application does not have to keep the string around after setting this option.

Default

NULL

Protocols

This functionality affects http only

Examples

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/*");
    curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
    /* issue an OPTIONS * request (no leading slash) */
    curl_easy_setopt(curl, CURLOPT_REQUEST_TARGET, "*");
    /* Perform the request */
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}

Return value

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3).

Releases

5 releases since Debian 10 (Buster); the text changed 4 times.

  1. 10
  2. 11
  3. 12
  4. 13
  5. Arch

Availability

Added in curl 7.55.0

From curl 8.23.0-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.