public static function headersToArray($header_text)
    {
        $headers = array();


        foreach (explode("\r\n", $header_text) as $i => $line)
            if ($i === 0)
                $headers['http_code'] = $line;
            else
            {
                if(!empty($line) && strpos($line, ':') !== false){
                    list ($key, $value) = explode(': ', $line);

                    $headers['headers'][] = array(
                        'key' => $key,
                        'value' => $value,
                    );
                }
            }

        return $headers;
    }