0
CURL *handle;
struct curl_slist *slist=NULL;
slist = curl_slist_append(slist, "X-libcurl: coolness");
slist = curl_slist_append(slist, "Authorization: Bearer retrffhj");

curl_slist_free_all(slist); /* clears all header list */

How can I clear the header with key Authorization and rest header information should be retained as it is.

2 Answers2

0
  1. clear the entire list
  2. make a new list with the header(s) you want in it
  3. use the new list
Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
0
list = curl_slist_append(list, "Accept:");

If you add a header with no content as in 'Accept:' (no data on the right side of the colon), the internally used header will get disabled.

https://curl.se/libcurl/c/CURLOPT_HTTPHEADER.html

TomJava
  • 499
  • 1
  • 8
  • 24