public static function createFromRequest(StreamInterface $stream, ServerRequestInterface $request = null)
    {
        $result = [];
        if ($request === null) {
            $headers = \tao_helpers_Http::getHeaders();
            $rangeHeader = isset($headers['Range']) ? [$headers['Range']] : null;
        } else {
            $rangeHeader = $request->hasHeader('Range') ? $request->getHeader('Range') : null;
        }
        if ($rangeHeader) {
            $ranges = explode(',', $rangeHeader[0]);
            foreach($ranges as $range) {
                $range = str_replace('bytes=', '', $range);
                $result[] = new StreamRange($stream, $range);
            }
        }
        return $result;
    }