private function reverse_chunk($s): string
    {
        $res = '';

        while (strlen($s)) {
            $pos = strpos($s, "\r\n");

            if ($pos === false) {
                $res .= $s;
                break;
            }

            $l = hexdec(substr($s, 0, $pos));
            $res .= substr($s, $pos + 2, $l);
            $s = substr($s, $l + $pos + 2);
        }

        return $res;
    }