HttpResponseHeaderCollection.Connection 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 HttpConnectionOptionHeaderValue 对象的 HttpConnectionOptionHeaderValueCollection ,这些对象表示 HTTP 响应上的 Connection HTTP 标头的值。
public:
property HttpConnectionOptionHeaderValueCollection ^ Connection { HttpConnectionOptionHeaderValueCollection ^ get(); };
HttpConnectionOptionHeaderValueCollection Connection();
public HttpConnectionOptionHeaderValueCollection Connection { get; }
var httpConnectionOptionHeaderValueCollection = httpResponseHeaderCollection.connection;
Public ReadOnly Property Connection As HttpConnectionOptionHeaderValueCollection
属性值
HttpConnectionOptionHeaderValue 对象的集合,这些对象表示 Connection HTTP 标头的值。 空集合表示标头不存在。
注解
下面的示例代码演示了一个方法,该方法使用 HttpResponseHeaderCollection 对象的 Connection 属性获取和设置 HttpResponseMessage 对象上的 Connection 标头。
// 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());
}