本文整理汇总了C#中IHttpEntity.SetHeader方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpEntity.SetHeader方法的具体用法?C# IHttpEntity.SetHeader怎么用?C# IHttpEntity.SetHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHttpEntity
的用法示例。
在下文中一共展示了IHttpEntity.SetHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTo
public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
{
//get the data block to be transferred
StreamedDataBlock dataBlock = (StreamedDataBlock)entity;
if (HttpContext.Current != null)
{
//disable buffering
HttpContext.Current.Response.BufferOutput = false;
if (dataBlock.BlockLength.HasValue)
{
//only set the content lengths, if we actually know it
response.SetHeader("Content-Length", dataBlock.BlockLength.Value.ToString(CultureInfo.InvariantCulture));
}
response.SetHeader("Content-Type", MediaType.ApplicationOctetStream.Name);
}
else
{
response.ContentLength = dataBlock.BlockLength;
response.ContentType = MediaType.ApplicationOctetStream;
}
//write the HTTP headers
VfsHttpHeaders headers = VfsHttpHeaders.Default;
response.SetHeader(headers.TransferId, dataBlock.TransferTokenId);
response.SetHeader(headers.BlockLength, dataBlock.BlockLength.ToString());
response.SetHeader(headers.BlockNumber, dataBlock.BlockNumber.ToString());
response.SetHeader(headers.IsLastBlock, dataBlock.IsLastBlock.ToString());
response.SetHeader(headers.BlockOffset, dataBlock.Offset.ToString());
using (dataBlock.Data)
{
//write data to response stream, then close the stream
dataBlock.Data.CopyTo(response.Stream);
}
}