Share via


HttpResponseHeaderCollection.TransferEncoding Property

Definition

Gets the HttpTransferCodingHeaderValueCollection of HttpTransferCodingHeaderValue objects that represent the value of a Transfer-Encoding HTTP header on an HTTP response.

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

Property Value

The collection of HttpTransferCodingHeaderValue objects that represent the value of a Transfer-Encoding HTTP header on an HTTP response. An empty collection means that the header is absent.

Remarks

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

// 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());
}

Applies to

See also