curl-library
Re: How to set/change single custom header?
Date: Fri, 12 Apr 2019 11:01:05 -0500
On Fri, Apr 12, 2019 at 05:13:38PM +0200, Daniel Stenberg wrote:
> On Thu, 11 Apr 2019, Grant Edwards via curl-library wrote:
>
> > Next, I'd like to change the value of _one_ of the custom headers each time
> > the request is perfomred. I can't figure out how to do that.
>
>[...]
>
> But you'll notice that 'struct curl_slist' is a very simply and public struct,
> so when use curl_slist_append() it just builds a linked list out of such
> structs. You can easily make your own functions to do the same and you can, if
> you want to, just fine the single header in that list that you want to update
> and update that specific node in the list between each new libcurl invocation.
Thanks!
I declared a static 'struct curl_slist' with 'data' pointing to a
static string buffer. I use that as the head of the linked list I
pass to CURLOPT_HTTPHEADER. Before each call to curl_easy_perform()
all I have to do is sprintf() the desired header into the static
string buffer. This is probably entirely too cleaver and will someday
cause endless confusion, but it's too good to resist.
> Or another take would be to create a whole set of lists to begin with and then
> just change between those pre-made lists while you do your requests.
Since the set size has no limit, I would need to create a new list
each time. That's not a big problem, but seems wasteful when all I
need to do is change the value of one header.
-- Grant ------------------------------------------------------------------- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.htmlReceived on 2019-04-12