curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Turning two command-line curl calls into c++, using libcurl

From: Daniel Stenberg via curl-library <curl-library_at_lists.haxx.se>
Date: Mon, 23 May 2022 17:22:23 +0200 (CEST)

On Mon, 23 May 2022, J via curl-library wrote:

> curl_easy_setopt( curl, CURLOPT_HEADER, "Content-Type:
> application/x-www-form-urlencoded" );

> curl_easy_setopt( curl, CURLOPT_HEADER, ( (
> (std::string)"Authorization: Bearer" ) + token ).c_str() );

These are wrong.

"CURLOPT_HEADER - pass headers to the data stream " this option is for asking
for headers to (also) get sent to the write callback. See
https://curl.se/libcurl/c/CURLOPT_HEADER.html

To tell libcurl HTTP headers to include in outgoing requests you want
CURLOPT_HTTPHEADER: https://curl.se/libcurl/c/CURLOPT_HTTPHEADER.html

But note that you pass in a list of headers to that option, not a single one.

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html
-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2022-05-23