Table of Contents

Class Headers

Namespace
Microsoft.Azure.Cosmos
Assembly
Microsoft.Azure.Cosmos.Client.dll

Header implementation used for Request and Responses

public class Headers : IEnumerable
Inheritance
Headers
Implements
Inherited Members
Extension Methods

Constructors

Headers()

Creates a new instance of Headers.

public Headers()

Properties

ActivityId

Gets the activity ID for the request from the Azure Cosmos DB service.

public virtual string ActivityId { get; }

Property Value

string

The activity ID for the request.

ContentLength

Gets the Content Length for the current content in the ResponseMessage.

public virtual string ContentLength { get; set; }

Property Value

string

ContentType

Gets the Content Type for the current content in the ResponseMessage.

public virtual string ContentType { get; }

Property Value

string

ContinuationToken

Gets the Continuation Token in the current ResponseMessage.

public virtual string ContinuationToken { get; }

Property Value

string

ETag

Gets the entity tag associated with the resource from the Azure Cosmos DB service.

public virtual string ETag { get; }

Property Value

string

The entity tag associated with the resource.

Remarks

ETags are used for concurrency checking when updating resources.

this[string]

Gets the value of a particular header.

public virtual string this[string headerName] { get; set; }

Parameters

headerName string

Header name to look for.

Property Value

string

The header value.

Location

Gets the Location for the current content in the ResponseMessage.

public virtual string Location { get; }

Property Value

string

RequestCharge

Gets the request charge for this request from the Azure Cosmos DB service.

public virtual double RequestCharge { get; }

Property Value

double

The request charge measured in request units.

Session

Gets the Session Token for the current ResponseMessage.

public virtual string Session { get; }

Property Value

string

Remarks

Session Token is used along with Session Consistency.

Methods

Add(string, IEnumerable<string>)

Adds a header to the Header collection.

public virtual void Add(string headerName, IEnumerable<string> values)

Parameters

headerName string

Header name.

values IEnumerable<string>

List of values to be added as a comma-separated list.

Add(string, string)

Adds a header to the Header collection.

public virtual void Add(string headerName, string value)

Parameters

headerName string

Header name.

value string

Header value.

AllKeys()

Obtains a list of all header names.

public virtual string[] AllKeys()

Returns

string[]

An array with all the header names.

Get(string)

Gets the value of a particular header.

public virtual string Get(string headerName)

Parameters

headerName string

Header name.

Returns

string

The header value.

GetEnumerator()

Enumerates all the HTTP headers names in the Headers.

public virtual IEnumerator<string> GetEnumerator()

Returns

IEnumerator<string>

An enumerator for all headers.

GetHeaderValue<T>(string)

Gets a header value with a particular type.

public virtual T GetHeaderValue<T>(string headerName)

Parameters

headerName string

Header name.

Returns

T

The header value parsed for a particular type.

Type Parameters

T

Type of the header value.

GetValueOrDefault(string)

Returns the header value or the default(string)

public virtual string GetValueOrDefault(string headerName)

Parameters

headerName string

Header Name

Returns

string

Returns the header value or the default(string).

Remove(string)

Removes a header from the header collection.

public virtual void Remove(string headerName)

Parameters

headerName string

Header name.

Set(string, string)

Adds or updates a header in the Header collection.

public virtual void Set(string headerName, string value)

Parameters

headerName string

Header name.

value string

Header value.

TryGetValue(string, out string)

Tries to get the value for a particular header.

public virtual bool TryGetValue(string headerName, out string value)

Parameters

headerName string

Header name.

value string

Header value.

Returns

bool

True or false if the header name existed in the header collection.

See Also