user_agent.php
protected function createRequest($url, $encoding)
    {
        $request = $this->createHttpRequest($url, $encoding);
        $this->addAdditionalHeaders($request);
        if ($this->cookies_enabled) {
            $request->readCookiesFromJar($this->cookie_jar, $url);
        }
        $this->authenticator->addHeaders($request, $url);

        // Add referer header, if not set explicitly
        if($this->http_referer) {
            $headers = $request->getHeaders();
            if(is_array($headers)) {
                $custom_referer = false;
                foreach ($headers as $header) {
                    if (preg_match('~^referer:~i', $header)) {
                        $custom_referer = true;
                        break;
                    }
                }
                if (! $custom_referer) {
                    $request->addHeaderLine('Referer: ' . $this->http_referer);
                }
            }
        }

        return $request;
    }
protected function createRequest($url, $encoding)
    {
        $request = $this->createHttpRequest($url, $encoding);
        $this->addAdditionalHeaders($request);
        if ($this->cookies_enabled) {
            $request->readCookiesFromJar($this->cookie_jar, $url);
        }
        $this->authenticator->addHeaders($request, $url);

        // Add referer header, if not set explicitly
        if($this->http_referer) {
            $headers = $request->getHeaders();
            if(is_array($headers)) {
                $custom_referer = false;
                foreach ($headers as $header) {
                    if (preg_match('~^referer:~i', $header)) {
                        $custom_referer = true;
                        break;
                    }
                }
                if (! $custom_referer) {
                    $request->addHeaderLine('Referer: ' . $this->http_referer);
                }
            }
        }

        return $request;
    }
Creates a full page request.

@param SimpleUrl $url                 Target to fetch as url object.
@param SimpleFormEncoding $encoding   POST/GET parameters.

@return SimpleHttpRequest             New request.