Parsing HTTP_RANGE header in PHP

前端 未结 3 895
广开言路
广开言路 2020-12-03 02:28

Is there an existing way to parse the HTTP_RANGE header correctly in PHP? Thought I\'d ask here before re-inventing the wheel.

I am currently using

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 02:37

    Taken from the PEAR Package HTTP_Download:

    function getRanges()
    {
        return preg_match('/^bytes=((\d*-\d*,? ?)+)$/', @$_SERVER['HTTP_RANGE'], $matches) ? $matches[1] : array();
    }
    

    It is also a good idea to use this packages for stuff like this!

提交回复
热议问题