src/Alexsoft/Curl.php
protected function parseResponse()
    {
        if (isset($this->response)) {
            list($responseParts['headersString'], $responseParts['body']) = explode("\r\n\r\n", $this->response, 2);
            $responseParts['body'] = htmlspecialchars($responseParts['body']);
            $headers = explode("\r\n", $responseParts['headersString']);

            $cookies = [];
            if (preg_match_all('/Set-Cookie: (.*?)=(.*?)(\n|;)/i', $responseParts['headersString'], $matches)) {
                if (!empty($matches)) {
                    foreach ($matches[1] as $key => $value) {
                        $cookies[$value] = $matches[2][$key];
                    }
                    $responseParts['cookies'] = $cookies;
                }
            }
            unset($responseParts['headersString']);

            $first = true;
            foreach ($headers as $header) {
                if ($first) {
                    list($responseParts['protocol'], $responseParts['statusCode']) = explode(' ', $header, 2);
                    $first = false;
                } else {
                    $tmp = (explode(': ', $header));
                    if ($tmp[0] === 'Set-Cookie') {
                        continue;
                    } else {
                        $responseParts['headersArray'][$tmp[0]] = $tmp[1];
                    }
                }
            }
            return $responseParts;
        } else {
            return null;
        }
    }
protected function parseResponse()
    {
        if (isset($this->response)) {
            list($responseParts['headersString'], $responseParts['body']) = explode("\r\n\r\n", $this->response, 2);
            $responseParts['body'] = htmlspecialchars($responseParts['body']);
            $headers = explode("\r\n", $responseParts['headersString']);

            $cookies = [];
            if (preg_match_all('/Set-Cookie: (.*?)=(.*?)(\n|;)/i', $responseParts['headersString'], $matches)) {
                if (!empty($matches)) {
                    foreach ($matches[1] as $key => $value) {
                        $cookies[$value] = $matches[2][$key];
                    }
                    $responseParts['cookies'] = $cookies;
                }
            }
            unset($responseParts['headersString']);

            $first = true;
            foreach ($headers as $header) {
                if ($first) {
                    list($responseParts['protocol'], $responseParts['statusCode']) = explode(' ', $header, 2);
                    $first = false;
                } else {
                    $tmp = (explode(': ', $header));
                    if ($tmp[0] === 'Set-Cookie') {
                        continue;
                    } else {
                        $responseParts['headersArray'][$tmp[0]] = $tmp[1];
                    }
                }
            }
            return $responseParts;
        } else {
            return null;
        }
    }
protected function parseResponse ( ) { if ( isset ( $ this -> response ) ) { list ( $ responseParts [ 'headersString' ] , $ responseParts [ 'body' ] ) = explode ( "\r\n\r\n" , $ this -> response , 2 ) ; $ responseParts [ 'body' ] = htmlspecialchars ( $ responseParts [ 'body' ] ) ; $ headers = explode ( "\r\n" , $ responseParts [ 'headersString' ] ) ; $ cookies = [ ] ; if ( preg_match_all ( '/Set-Cookie: (.*?)=(.*?)(\n|;)/i' , $ responseParts [ 'headersString' ] , $ matches ) ) { if ( ! empty ( $ matches ) ) { foreach ( $ matches [ 1 ] as $ key => $ value ) { $ cookies [ $ value ] = $ matches [ 2 ] [ $ key ] ; } $ responseParts [ 'cookies' ] = $ cookies ; } } unset ( $ responseParts [ 'headersString' ] ) ; $ first = true ; foreach ( $ headers as $ header ) { if ( $ first ) { list ( $ responseParts [ 'protocol' ] , $ responseParts [ 'statusCode' ] ) = explode ( ' ' , $ header , 2 ) ; $ first = false ; } else { $ tmp = ( explode ( ': ' , $ header ) ) ; if ( $ tmp [ 0 ] === 'Set-Cookie' ) { continue ; } else { $ responseParts [ 'headersArray' ] [ $ tmp [ 0 ] ] = $ tmp [ 1 ] ; } } } return $ responseParts ; } else { return null ; } }
Method which parses cURL response
@return array|NULL
Method which parses cURL response