前言
前情回顧:上一篇我們遺留了兩個(gè)問(wèn)題,一個(gè)是未完全實(shí)現(xiàn)斷點(diǎn)續(xù)傳,另外則是在響應(yīng)時(shí)是返回StreamContent還是PushStreamContent呢?這一節(jié)我們重點(diǎn)來(lái)解決這兩個(gè)問(wèn)題,同時(shí)就在此過(guò)程中需要注意的地方一并指出,若有錯(cuò)誤之處,請(qǐng)指出。
StreamContent compare to PushStreamContent
我們來(lái)看看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