Problem description
The origin server returned an invalid Content-Range or Content-Length header in response to a Range request forwarded by a mirroring-based back-to-origin rule.
Causes
When OSS forwards a Range request to the origin server, the origin must return a valid Content-Range or Content-Length header so OSS can reconstruct and serve the requested byte range. If either header is missing or malformed, OSS cannot validate the response size and returns this error instead of serving partial content.
Examples
The following conditions all trigger this error:
The
Content-Rangeheader is missing from the origin response.The
Content-Rangeheader is present but uses an invalid format.The
Content-Lengthheader is missing from the origin response.The
Content-Lengthheader is present but uses an invalid format.The byte range length in
Content-Rangeis inconsistent with the value inContent-Length.
A valid origin response to a Range request looks like the following:
HTTP/1.1 206 Partial Content
Content-Type: application/octet-stream
Content-Length: 1024
Content-Range: bytes 0-1023/146515The Content-Range header uses the format bytes <start>-<end>/<total>, where:
<start>-<end>is the returned byte range (zero-indexed, inclusive).<total>is the total resource size in bytes. Use*if the total size is unknown.
Content-Length must equal the number of bytes in the range, not the total resource size. In the example above, Content-Length: 1024 matches the 1,024 bytes in bytes 0-1023.
Solutions
Verify that the origin server returns valid Content-Range and Content-Length headers for Range requests.
Run the following command against your origin server to inspect the response headers:
curl -v -H "Range: bytes=0-1023" <origin-url>In the response, confirm that:
The status code is
206 Partial Content.The
Content-Rangeheader is present and follows the formatbytes <start>-<end>/<total>.The
Content-Lengthheader is present and matches the byte count of the returned range.
If the origin does not return a 206 status or omits either header, update the origin server configuration to comply with RFC 7233.