共用方式為


HttpResponseHeaderCollection.TransferEncoding 屬性

定義

取得 HttpTransferCodingHeaderValueCollectionHttpTransferCodingHeaderValue 物件,這些物件代表 HTTP 回應上 Transfer-Encoding HTTP 標頭的值。

public:
 property HttpTransferCodingHeaderValueCollection ^ TransferEncoding { HttpTransferCodingHeaderValueCollection ^ get(); };
HttpTransferCodingHeaderValueCollection TransferEncoding();
public HttpTransferCodingHeaderValueCollection TransferEncoding { get; }
var httpTransferCodingHeaderValueCollection = httpResponseHeaderCollection.transferEncoding;
Public ReadOnly Property TransferEncoding As HttpTransferCodingHeaderValueCollection

屬性值

HttpTransferCodingHeaderValue物件的集合,代表 HTTP 回應上Transfer-Encoding HTTP 標頭的值。 空集合表示標頭不存在。

備註

下列範例程式碼示範在HttpResponseMessage物件上使用 TransferEncoding 屬性取得及設定HttpResponseMessage物件上的Transfer-Encoding標頭的方法。

// HttpTransferCodingHeaderValueCollection
// HttpTransferCodingHeaderValue hasValue (string) and Parameters (IList<HttpNameValueHeaderValue>)
// IList<HttpNameValueHeaderValue>
// HttpNameValueHeaderValue
//
// This is the same type as on the Request TransferEncoding  value
void DemoTransferEncoding(HttpResponseMessage response) {
    var h = response.Headers;
    h.TransferEncoding.TryParseAdd("Basic");
    h.TransferEncoding.Add(new HttpTransferCodingHeaderValue("gzip"));

    var header = h.TransferEncoding;
    uiLog.Text += "\nTRANSFER ENCODING HEADER\n";
    foreach (var item in header) {
        // Parameters is an IList<HttpNameValueHeaderValue> of Name/Value strings
        var parameterString = "";
        foreach (var parameter in item.Parameters) {
            parameterString += string.Format("[{0}={1}] ", parameter.Name, parameter.Value);
        }
        if (parameterString == "") {
            parameterString = "(no parameters)";
        }
        uiLog.Text += string.Format("Value: {0} Parameters: {1} ToString(): {2}\n", item.Value, parameterString, item.ToString());
    }
    uiLog.Text += String.Format("TransferEncoding: {0}\n", header.ToString());
}

適用於

另請參閱