PicoFeed\Client\Curl::handleRedirection PHP Method

handleRedirection() private method

Handle HTTP redirects
private handleRedirection ( string $location ) : array
$location string Redirected URL
return array
    private function handleRedirection($location)
    {
        $nb_redirects = 0;
        $result = array();
        $this->url = Url::resolve($location, $this->url);
        $this->body = '';
        $this->body_length = 0;
        $this->response_headers = array();
        $this->response_headers_count = 0;
        while (true) {
            ++$nb_redirects;
            if ($nb_redirects >= $this->max_redirects) {
                throw new MaxRedirectException('Maximum number of redirections reached');
            }
            $result = $this->doRequest();
            if ($this->isRedirection($result['status'])) {
                $this->url = Url::resolve($result['headers']['Location'], $this->url);
                $this->body = '';
                $this->body_length = 0;
                $this->response_headers = array();
                $this->response_headers_count = 0;
            } else {
                break;
            }
        }
        return $result;
    }