mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
A distribution ignored a viewer's Range header: an S3 origin answered every GET with the whole object and 200, while advertising Accept-Ranges: bytes, and a custom origin behind a cache or origin request policy never saw the header, so seeking in a video or resuming a download read the object from the start. An S3 origin now serves the one byte range asked for as 206 with its Content-Range, read from the snapshot GetObject serves, and answers 416 when the range starts past the end of the object. Any other Range gets the whole object, as CloudFront answers a Range it does not accept and as S3 does not serve several ranges in one request. A custom origin gets the viewer's Range and If-Range on every GET or HEAD with a Range whatever the forwarding settings, as CloudFront forwards a range GET to the origin and a HEAD can then report the range's length, and its answer is passed on. A custom error page is served whole. A Range now applies only while the If-Range sent with it, if any, still describes the object: a strong ETag equal to the object's, or an HTTP-date equal to its Last-Modified, matched exactly as RFC 9110 section 13.1.5 requires. Otherwise the whole object is served. This holds for GetObject, HeadObject and the S3 origin. A presigned URL that signs Range must also sign an If-Range the request carries, as the S3 User Guide requires. HeadObject honors Range as the API Reference describes: a satisfiable range sets Content-Length to the length of the range, leaving out the whole-object checksum as a ranged GetObject does, and one past the end answers 416, while a Range that is not one valid range is ignored, as before. An S3 origin answers a HEAD the same way. A ranged GetObject is now recorded in CloudTrail like any other, with the bytes of the range sent, and a range past the end of the object, for GetObject or HeadObject, is recorded as InvalidRange. The range parsing GetObject did is now ByteRange, which both use, and UploadPartCopy's range stream becomes ByteRangeInputStream. GetObject now matches the range unit in any case, as RFC 9110 section 14.1 has it, and its InvalidRange error is the one S3 sends, as an AWS-validated LocalStack capture records it: the message "The requested range is not satisfiable", with no trailing period, and the RangeRequested and ActualObjectSize fields.