public final function getArrayOfHeadersFromRawHeaderString($rawHeaderString)
    {
        // split headers, one per array element
        if (is_string($rawHeaderString)) {

            // tolerate line terminator: CRLF = LF (RFC 2616 19.3)
            $rawHeaderString = str_replace("\r\n", "\n", $rawHeaderString);

            // unfold folded header fields. LWS = [CRLF] 1*(SP | HT) <US-ASCII SP, space (32)>, <US-ASCII HT, horizontal-tab (9)> (RFC 2616 2.2)
            $rawHeaderString = preg_replace('/\n[ \t]/', ' ', $rawHeaderString);

            // create the headers array
            $headers = explode("\n", $rawHeaderString);

        } else {

            $headers = array();
        }

        $toReturn = array();

        foreach ($headers as $header) {

            if (empty($header) || strpos($header, ':') === false) {

                continue;
            }

            list($headerName, $headerValue) = explode(':', $header, 2);

            if (empty($headerValue)) {

                continue;
            }

            if (isset($toReturn[$headerName])) {

                if (!is_array($toReturn[$headerName])) {

                    $toReturn[$headerName] = array($toReturn[$headerName]);
                }

                $toReturn[$headerName][] = trim($headerValue);

            } else {

                $toReturn[$headerName] = trim($headerValue);
            }
        }

        return $toReturn;
    }