private function parseResult(string $result): PageFetcherResponseInterface
    {
        $resultParts = explode("\r\n\r\n", $result, 2);

        $headers = explode("\r\n", $resultParts[0]);
        $statusLine = array_shift($headers);
        $statusLineParts = explode(' ', $statusLine);
        $httpCode = intval($statusLineParts[1]);
        if ($httpCode === 100) {
            return $this->parseResult($resultParts[1]);
        }

        $content = count($resultParts) > 1 ? $resultParts[1] : '';

        $response = new PageFetcherResponse($httpCode, $content);
        foreach ($headers as $header) {
            $response->addHeader(trim($header));
        }

        return $response;
    }
private function parseResult(string $result): PageFetcherResponseInterface
    {
        $resultParts = explode("\r\n\r\n", $result, 2);

        $headers = explode("\r\n", $resultParts[0]);
        $statusLine = array_shift($headers);
        $statusLineParts = explode(' ', $statusLine);
        $httpCode = intval($statusLineParts[1]);
        if ($httpCode === 100) {
            return $this->parseResult($resultParts[1]);
        }

        $content = count($resultParts) > 1 ? $resultParts[1] : '';

        $response = new PageFetcherResponse($httpCode, $content);
        foreach ($headers as $header) {
            $response->addHeader(trim($header));
        }

        return $response;
    }
private function parseResult ( string $ result ) : PageFetcherResponseInterface { $ resultParts = explode ( "\r\n\r\n" , $ result , 2 ) ; $ headers = explode ( "\r\n" , $ resultParts [ 0 ] ) ; $ statusLine = array_shift ( $ headers ) ; $ statusLineParts = explode ( ' ' , $ statusLine ) ; $ httpCode = intval ( $ statusLineParts [ 1 ] ) ; if ( $ httpCode === 100 ) { return $ this -> parseResult ( $ resultParts [ 1 ] ) ; } $ content = count ( $ resultParts ) > 1 ? $ resultParts [ 1 ] : '' ; $ response = new PageFetcherResponse ( $ httpCode , $ content ) ; foreach ( $ headers as $ header ) { $ response -> addHeader ( trim ( $ header ) ) ; } return $ response ; }
Parses the CURL result into a PageFetcherResponse.

@param string $result The CURL result.

@return PageFetcherResponseInterface The PageFetcherResponse.
Parses the CURL result into a PageFetcherResponse .