WebAPI中HttpContent: StreamContent 和 PushStreamContent 的使用场景

PushStreamContent与StreamContent的区别
本文探讨了PushStreamContent与StreamContent在WebAPI场景下的使用区别。PushStreamContent适用于实时推送数据到流的情况,例如流媒体视频;而StreamContent则更适合于允许用户下载文件的场景。当内容长度未知且数据接收同时进行时,如流媒体视频场景,使用PushStreamContent并通过分块传输编码发送响应。

PushStreamContent is for scenarios where you need to 'push' data to the stream, where as StreamContent 'pulls' data from the stream. 


example:

if I want to "stream" content in the "streaming video" sense of the word use PushStreamContent but if I want to let someone "download a file" then use StreamContent

The "streaming video" scenario is one, where you do not know the total content length upfront and you are writing to the destination stream as you are receiving the video feed from somewhere. This is the reason when using PushStreamContent response is sent in chunked transfer encoding as we do not know the content length upfront. 


http://stackoverflow.com/questions/16168683/webapi-streamcontent-vs-pushstreamcontent

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值