Skip to content

libcURL.EasyHandle.SetRequestHeader

Andrew Lambert edited this page Sep 15, 2015 · 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.
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.

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 headers As libcURL.ListPtr
 headers = curl.SetRequestHeader("First", "Header") ' set header
 headers = curl.SetRequestHeader(headers, "Second", "Header") ' append header
 headers = curl.SetRequestHeader(headers, "First", "") ' clear header by name
 headers = curl.SetRequestHeader(headers, "", "") ' clear all headers

##See also

Clone this wiki locally