Skip to main content

parse_range_header

Function parse_range_header 

Source
pub fn parse_range_header(
    range: &str,
    file_size: u64,
) -> Result<RangeSpec, RangeError>
Expand description

解析 Range 头(对齐 Webman sendFileexplode('=', ..., 2) + explode('-', ...)

支持三种格式(对齐 HTTP/1.1 Range 规范):

  • bytes=0-499 → RangeSpec { start: 0, end: 499 }
  • bytes=500- → RangeSpec { start: 500, end: file_size - 1 }
  • bytes=-500 → 最后 500 字节,RangeSpec { start: file_size-500, end: file_size-1 }

PHP Webman 仅支持 bytes=start-endbytes=start-,不支持 bytes=-suffix。 Rust 实现完整支持三种格式,超出 PHP 对齐范围但符合 HTTP 规范。