HTTP 1.1 provides support for range headers – it allows you to specify range headers to enable the client to retrieve partial response.

This can be used to retrieve partial content when working over HTTP.
It’s a technique that’s widely used when streaming video files, for instance.With this approach, rather than retrieving the entire data at one go, your application can retrieve the data partially, in chunks.

This feature can be particularly helpful in scenarios when the client needs to recover the data from interrupted connections that might occur due to cancelled requests, or connections to the server that have been dropped.The HTTP 206 Partial Content status code and its associated headers enable the clients or the web browsers to retrieve partial content in lieu of the complete content when a request is sent. Note that most modern-day web servers provide support for range requests.

The ByteRangeStreamContent class that has been added to WebAPI makes it easier to work with range requests.

The ByteRangeStreamContent class works similarly to how, let’s say, StreamContent works – with the exception that it can provide a view over a stream that is seekable. Note that a MemoryStream or a FileStream is seekable, i.e., they can be used to do ranges over them.To read this article in full or to leave a comment, please click here

Leave a Reply