Header Class

Definition

The Header class defines a SIP header.. A Header instance may belong to multiple HeaderCollection instances. The Header class is derived from the System.Object class.

public ref class Header : Microsoft::Rtc::Sip::Impl::ReplicatedObject
public class Header : Microsoft.Rtc.Sip.Impl.ReplicatedObject
Public Class Header
Inherits ReplicatedObject
Inheritance

Examples

The following code sample sends a redirection response with the new endpoint address in the "Contact" header. Requests are dispatched to this method from the MSPL script in the application manifest by using the Dispatch MSPL function.

public void OnRequest(object sender, RequestReceivedEventArgs rreArgs)
{

// Send a generic response to the sender indicating redirection (302).

Response response = rreArgs.Request.CreateResponse(302);

response.ReasonPhrase = "Redirected by Lync Server";

// Add the "Contact" header indicating the new redirection address of the SIP user.
// In this example, the localhost is supplied; in a real application, the second
// parameter of the Header constructor would be the redirection address of the user.

Header h = new Header("Contact", "sip:127.0.0.1:5060;transport=tcp");
response.AllHeaders.Add(h);

// Send the response.
rreArgs.ServerTransaction.SendResponse(response);

}

Remarks

This class is intended as a base class for some header types. Static constructor methods are provided.

A SIP header field is represented as type: value *(;parameter-name=parameter-value). The header type is a specific name, such as "Via", "Subject", or "Route". The header value is a string value corresponding to the type. The optional parameter list occurs after the value, with each parameter name/value pair separated from the header value and the other parameters by a semicolon.

Constructors

Header()

The Header constructor initializes a new instance of the Header class without a specified type or value.

Header(Header+StandardHeaderType)

Creates a new header object with a specified standard header type.

Header(Header+StandardHeaderType, String)

Creates a new header object with a specified standard header type and value.

Header(String)

Creates a new header object with a specified header type.

Header(String, String)

The Header constructor creates a new instance of the Header class of the specified SIP header type, with the specified value.

Fields

parameters

Private storage of header parameters. Derived classes may either use this field for their storage, or provide their own. This field is used by this class's implementation of the GetParameters() and SetParameters(NameValueCollection) method.

state (Inherited from ReplicatedObject)
value

Private storage of the header value. Derived classes may either use this field for their storage, or provide their own. This field is used by this class's implementation of GetValue() and SetValue(String).

valueNoParameters

Index into header of end of the value portion, excluding parameters. Classes may either use this field for their storage, or provide their own. This field is used by this class's implementation of GetValueNoParameters() and SetValueNoParameters(String).

Properties

IsReadOnly

The IsReadOnly property indicates whether the SIP header is read-only.

Parameters

The Parameters property contains the parameters for the SIP header as a collection of name/value pairs.

StandardType

Efficient representation of common SIP header types.

Type

The Type property contains the SIP header type as a string.

Value

The Value property contains the SIP header value as a string.

ValueNoParameters

The ValueNoParameters property contains the SIP header value as a string, minus any attached parameters.

Methods

GetParameters()

Protected method that is used to retrieve header parameters. Derived classes can override this method, for example, to synthesize parameters from an internal representation.

GetValue()

Protected method that is used to retrieve the header value. Derived classes can override this method, for example, to synthesize the value from an internal representation.

GetValueNoParameters()

Protected method that is used to retrieve the header value without parameters. Derived classes can override this method, for example, to synthesize the value from an internal representation.

InitializeMarshaled(ServerAgent, ObjectSpace, UInt32) (Inherited from ReplicatedObject)
InitializeUnmarshaled(ReplicatedObject) (Inherited from ReplicatedObject)
InitializeUnmarshaled(ServerAgent, ObjectSpace) (Inherited from ReplicatedObject)
ParseHeaderValue(Boolean)

Protected helper method that parses a string into a header value and parameters.

SetMarshaled()

Updates state to Marshaled.

SetParameters(NameValueCollection)

Protected method that is used to set header parameters. Derived classes can override this method, for example, to parse parameters into an internal representation.

SetValue(String)

Protected method that is used to set the header value. A derived class can override this method, for example, to parse the value into an internal representation.

SetValueNoParameters(String)

Protected method that is used to set the header value without parameters. A derived class can override this method, for example, to parse the value into an internal representation.

Applies to