Table of Content
The Content-Range header is a fundamental element of HTTP protocol specifically purposed for conveying information about partial content in the context of HTTP transactions. This header facilitates the communication about where the partial data fits in the full context. It becomes particularly beneficial during instances when a complete transmission of data isn't possible, and only segments of data are being sent. The Content-Range header formats the understandable selection parameters for inputs such as start and end positions, and file's total length.
Content-Range: <unit> <range-start>-<range-end>/<size>
Unit: An identifier which represents the range unit. Byte ranges are usually communicated with "bytes", but any token is acceptable.
Range-start and range-end: The inclusive boundaries of the range.
Size: Total length of the data. "*" can be used if the size is unknown.
When working with byte ranges:
Content-Range: bytes 0-1023/146515
This specifies that the server is delivering bytes ranging from 0 to 1023 out of the total 146515 bytes.
How to modify Content-Range header
ModHeader is a powerful Chrome extension for modifying HTTP request and response headers. It can be used to modify the Content-Range header to simulate different content range scenarios for testing and development purposes.
Firstly, install ModHeader from the Chrome Web Store. After installation, click on the ModHeader icon in the Chrome toolbar, and then "+" to add a new header. In the name field, type 'Content-Range', and in the Value field, type your desired range value, following the standard format like 'bytes 100-200/1000'.
Upon setting this up, all future HTTP requests originating from your browser will have the modified Content-Range header. This simulates the response from a server that sends segmented content, a useful tool for any developer testing their handling of partial content scenarios.