curb icon indicating copy to clipboard operation
curb copied to clipboard

Is CURLOPT_REQUEST_TARGET needed for Request-URI different than Host header?

Open decal opened this issue 4 years ago • 2 comments

I'm wondering if CURLOPT_REQUEST_TARGET would need to be added to curb in order to perform requests where the Request-URI is different than the HTTP request's Host header (see code block below.) Perhaps there is another way to do this with Curl::Easy that I am unaware of. Please advise!

GET http://localhost HTTP/1.1
Host: google.com

decal avatar Aug 14 '21 13:08 decal

@decal i think maybe. If you send me a patch I could take a look more

taf2 avatar Feb 13 '22 17:02 taf2

@decal reading the libcurl docs on this it looks like it's for setting OPTIONS request headers see: https://curl.se/libcurl/c/CURLOPT_REQUEST_TARGET.html

curl = curl_easy_init();
if(curl) {
  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 */
  curl_easy_perform(curl);
}

taf2 avatar Dec 27 '22 14:12 taf2