前言
前情回顧:上一篇我們遺留了兩個問題,一個是未完全實現(xiàn)斷點續(xù)傳,另外則是在響應時是返回StreamContent還是PushStreamContent呢?這一節(jié)我們重點來解決這兩個問題,同時就在此過程中需要注意的地方一并指出,若有錯誤之處,請指出。
StreamContent compare to PushStreamContent
我們來看看StreamContent代碼,如下:
public class StreamContent : HttpContent { // Fields private int bufferSize; private Stream content; private bool contentConsumed; private const int defaultBufferSize = 0x1000; private long start; // Methods public StreamContent(Stream content); ] public StreamContent(Stream content, int bufferSize); protected override Task<Stream> CreateContentReadStreamAsync(); protected override void Dispose(bool disposing); private void PrepareContent(); protected override Task SerializeToStreamAsync(Stream stream, TransportContext context); protected intern