public static function parseHeaders($headers)
    {
        $httpCode  = null;
        $result    = null;
        $processed = [];

        foreach (explode(HttpHelper::EOL, $headers) as $lineNumber => $line) {
            if ($lineNumber === 0) {
                // first line of result is special
                if (preg_match("/^HTTP\/\d+\.\d+\s+(\d+)/", $line, $matches)) {
                    $httpCode = (int) $matches[1];
                }
                $result = $line;
            } else {
                // other lines contain key:value-like headers
                // the following is a performance optimization to get rid of
                // the two trims (which are expensive as they are executed over and over) 
                if (strpos($line, ': ') !== false) {
                    list($key, $value) = explode(': ', $line, 2);
                } else {
                    list($key, $value) = explode(':', $line, 2);
                }
                $processed[strtolower($key)] = $value;
            }
        }

        return [$httpCode, $result, $processed];
    }