Skip to content

libcURL.EasyHandle.SetRequestHeader

Andrew Lambert edited this page Nov 26, 2022 · 19 revisions

libcURL.EasyHandle.SetRequestHeader

Method Signature

 Function SetRequestHeader(Optional List As libcURL.ListPtr, Name As String, Value As String) As libcURL.ListPtr

Parameters

Name Type Comment
List ListPtr Optional. If specified, the return value from a previous call to this method (or any existing list of headers.)
Name String The header name. If the header already exists it will be replaced. Pass an empty string to clear all headers previously set by this function.
Value String The header value. Pass an empty string to clear the named header

Return value

A reference to a ListPtr which represents all the headers added so far. Pass this value back to this method as List to append the next header. Returns Nil if no headers exist.

Remarks

This method updates the List of headers that will be used in the next request. You must maintain a reference to the List until it is no longer in use by libcURL. Pass the List reference back to this function when adding subsequent headers. This pattern eases safe handling and disposal of the List reference by making the caller responsible for maintaining the reference.

If the named header does not already exist then it is appended to the List. If the header exists then the header is updated; if Value is "" (empty string) then the header is removed.

If Name is "" (empty string) then any previously set headers will be cleared, libcURL's default headers are reinstated, and this function returns Nil. The List may then be safely destroyed.

If List is not specified (and Name<>"") then a new List is returned.

Syntax example

 Dim curl As New libcURL.EasyHandle
 Dim h As libcURL.ListPtr = curl.SetRequestHeader("First", "Header") ' set header
 h = curl.SetRequestHeader(h, "Second", "Header") ' append header
 h = curl.SetRequestHeader(h, "First", "") ' clear header by name
 h = curl.SetRequestHeader(h, "", "") ' clear all headers

See also

Clone this wiki locally