/** * Parses the header string into an associative array. * @param string $headerString * @return \BluePsyduck\MultiCurl\Utils\Collection */ protected function parseHeaders($headerString) { $result = new Collection(); foreach (array_filter(explode("\r\n\r\n", $headerString)) as $responseHeader) { $header = new Collection(); foreach (explode("\r\n", $responseHeader) as $headerLine) { $parts = explode(':', $headerLine, 2); if (count($parts) === 2) { $header->set(trim($parts[0]), trim($parts[1])); } } $result->push($header); } return $result; }