SocketTools .NET Edition

HttpClient.AddHeaders Method 

Add one or more request headers.

[Visual Basic]
Public Function AddHeaders( _
   ByVal headerList As String _
) As Boolean
[C#]
public bool AddHeaders(
   string headerList
);

Return Value

This method returns a Boolean value. If the method succeeds, the return value is true. If the method fails, the return value is false.

Remarks

The AddHeaders method enables your application to set multiple header values by providing a list of name/value pairs separated by a colon, with each pair separated with a newline character. This function is similar to calling the SetHeader method for each value. When the list of header values is parsed, extraneous whitespace is ignored.

Exercise caution when providing a header list created directly from user input, such as a list of values input using a textbox control. Any header values which have been previously set by your application can be overridden by this method and may yield unpredictable results. If the service you are using requires a custom authorization header, such as an API token or other user credentials, allowing users to directly modify request header values this way can present a security risk.

See Also

HttpClient Class | SocketTools Namespace | GetHeader Method | SetHeader Method