private function header2Array($str)
    {
        if (is_array($str)) return $str;
        
        $result = [];
        $array = explode("\n", trim(str_replace("\r\n", "\n", $str), "\n"));
        foreach($array as $i => $line) {
            if ($i === 0) {
                $result['Http-Status'] = $line; // "HTTP/1.1 200 OK"
            } else {
                $header = explode(':', $line, 2);
                if (!$header[0]) continue;
                
                if (isset($header[1])) {
                    $result[trim($header[0])] = trim($header[1]);
                } else {
                    $result[] = trim($header[0]);
                }
            }
        }
        return $result;
    }
private function header2Array($str)
    {
        if (is_array($str)) return $str;
        
        $result = [];
        $array = explode("\n", trim(str_replace("\r\n", "\n", $str), "\n"));
        foreach($array as $i => $line) {
            if ($i === 0) {
                $result['Http-Status'] = $line; // "HTTP/1.1 200 OK"
            } else {
                $header = explode(':', $line, 2);
                if (!$header[0]) continue;
                
                if (isset($header[1])) {
                    $result[trim($header[0])] = trim($header[1]);
                } else {
                    $result[] = trim($header[0]);
                }
            }
        }
        return $result;
    }
private function header2Array ( $ str ) { if ( is_array ( $ str ) ) return $ str ; $ result = [ ] ; $ array = explode ( "\n" , trim ( str_replace ( "\r\n" , "\n" , $ str ) , "\n" ) ) ; foreach ( $ array as $ i => $ line ) { if ( $ i === 0 ) { $ result [ 'Http-Status' ] = $ line ; // "HTTP/1.1 200 OK" } else { $ header = explode ( ':' , $ line , 2 ) ; if ( ! $ header [ 0 ] ) continue ; if ( isset ( $ header [ 1 ] ) ) { $ result [ trim ( $ header [ 0 ] ) ] = trim ( $ header [ 1 ] ) ; } else { $ result [ ] = trim ( $ header [ 0 ] ) ; } } } return $ result ; }
parse header to array
@param  $str
@return array
parse header to array