protected function parseResponseHeadersAsArray($headers)
    {
        if (empty($headers)) return [];

        $headersArray = [];

        foreach (preg_split('#[\r\n]+#', $headers) as $headerString) {

            if ( ! preg_match('#^\s*(?<name>.*?)\s*:\s*(?<value>.*)\s*$#', $headerString, $matches)) continue;

            $headersArray[ $matches['name'] ] = $matches['value'];
        }

        return $headersArray;
    }
protected function parseResponseHeadersAsArray($headers)
    {
        if (empty($headers)) return [];

        $headersArray = [];

        foreach (preg_split('#[\r\n]+#', $headers) as $headerString) {

            if ( ! preg_match('#^\s*(?<name>.*?)\s*:\s*(?<value>.*)\s*$#', $headerString, $matches)) continue;

            $headersArray[ $matches['name'] ] = $matches['value'];
        }

        return $headersArray;
    }
protected function parseResponseHeadersAsArray ( $ headers ) { if ( empty ( $ headers ) ) return [ ] ; $ headersArray = [ ] ; foreach ( preg_split ( '#[\r\n]+#' , $ headers ) as $ headerString ) { if ( ! preg_match ( '#^\s*(?<name>.*?)\s*:\s*(?<value>.*)\s*$#' , $ headerString , $ matches ) ) continue ; $ headersArray [ $ matches [ 'name' ] ] = $ matches [ 'value' ] ; } return $ headersArray ; }
Parses a header string to an array

@param null|string $headers
@return array
Parses a header string to an array