user_agent.php
public function fetchResponse($url, $encoding)
    {
        if (!in_array($encoding->getMethod(), array('POST', 'PUT'))) {
            $url->addRequestParameters($encoding);
            $encoding->clear();
        }
        $response = $this->fetchWhileRedirected($url, $encoding);
        if ($headers = $response->getHeaders()) {
            if ($headers->isChallenge()) {
                $this->authenticator->addRealm(
                        $url,
                        $headers->getAuthentication(),
                        $headers->getRealm());
            }
        }

        return $response;
    }
public function fetchResponse($url, $encoding)
    {
        if (!in_array($encoding->getMethod(), array('POST', 'PUT'))) {
            $url->addRequestParameters($encoding);
            $encoding->clear();
        }
        $response = $this->fetchWhileRedirected($url, $encoding);
        if ($headers = $response->getHeaders()) {
            if ($headers->isChallenge()) {
                $this->authenticator->addRealm(
                        $url,
                        $headers->getAuthentication(),
                        $headers->getRealm());
            }
        }

        return $response;
    }
Fetches a URL as a response object. Will keep trying if redirected.
It will also collect authentication realm information.

@param string/SimpleUrl $url      Target to fetch.
@param SimpleEncoding   $encoding Additional parameters for request.

@return SimpleHttpResponse Hopefully the target page.