Re: CURLOPT_HTTPHEADER appends headers but does not delete old ones

Daniel Stenberg via curl-users <[email protected]> Sun, 17 May 2026 00:58:40 +0200 (CEST)
Newsgroups gmane.comp.web.curl.general
Message-ID <[email protected]>
On Fri, 15 May 2026, Mac-Fly via curl-users wrote:

(As this is a libcurl using question, the curl-library is the proper mailing 
list to send it to.)

> I have a strange effect that I see in one of my projects where I am setting 
> up header entries provided as a list derived from user settings. I am using 
> the code below that is supposed to delete old header entries, then collect 
> the ones to be applied and finally applies the entries. To my understanding, 
> this should only include the headers that I add in this respective call. 
> Instead, what happens is that the previous ones remain active and the ones I 
> append in further calls to that function are being added additionally. I was 
> following the example in: https://curl.se/libcurl/c/CURLOPT_HTTPHEADER.html

That sounds strange.

If you can extend the example code to reproduce the problem we can have a 
closer look at it.

-- 

  / daniel.haxx.se || https://rock-solid.curl.dev
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html