HttpResponseHeaderCollection.Connection | connection property

Applies to Windows and Windows Phone

Gets the HttpConnectionOptionHeaderValueCollection of HttpConnectionOptionHeaderValue objects that represent the value of a Connection HTTP header on an HTTP response.

Syntax


var connection = httpResponseHeaderCollection.connection;

Property value

Type: HttpConnectionOptionHeaderValueCollection

The collection of HttpConnectionOptionHeaderValue objects that represent the value of a Connection HTTP header. An empty collection means that the header is absent.

Remarks

The following sample code shows a method to get and set the Connection header on an HttpResponseMessage object using the Connection property on the HttpResponseHeaderCollection object.


// Connection:keep-alive
// HttpConnectionOptionHeaderValueCollection, a collection of
// HttpConnectionOptionHeaderValue which just has a Token (string)
// 
// This is the same type as on the request
    void DemoConnection(HttpResponseMessage response) {
        var h = response.Headers;
        h.Connection.TryParseAdd("close");
        h.Connection.TryParseAdd("some,values");
        h.Connection.Add(new HttpConnectionOptionHeaderValue("last"));

        var header = h.Connection;
        uiLog.Text += "\nCONNECTION HEADER\n";
        foreach (var item in header) {
            uiLog.Text += String.Format("Token: {0}  ToString: {1}\n", item.Token, item.ToString());
        }
        uiLog.Text += String.Format("Connection: {0}\n", header.ToString());
    }


Requirements

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Web.Http.Headers
Windows::Web::Http::Headers [C++]

Metadata

Windows.winmd

See also

HttpConnectionOptionHeaderValue
HttpConnectionOptionHeaderValueCollection
HttpResponseHeaderCollection
HttpResponseMessage
HttpResponseMessage.Headers

 

 

Show:
© 2014 Microsoft