/** * Queue a purge operation * * @param string $url */ public function queuePurge($url) { global $wgSquidPurgeUseHostHeader; $url = SquidUpdate::expand(str_replace("\n", '', $url)); $request = array(); if ($wgSquidPurgeUseHostHeader) { $url = wfParseUrl($url); $host = $url['host']; if (isset($url['port']) && strlen($url['port']) > 0) { $host .= ":" . $url['port']; } $path = $url['path']; if (isset($url['query']) && is_string($url['query'])) { $path = wfAppendQuery($path, $url['query']); } $request[] = "PURGE {$path} HTTP/1.1"; $request[] = "Host: {$host}"; } else { $request[] = "PURGE {$url} HTTP/1.0"; } $request[] = "Connection: Keep-Alive"; $request[] = "Proxy-Connection: Keep-Alive"; $request[] = "User-Agent: " . Http::userAgent() . ' ' . __CLASS__; // Two ''s to create \r\n\r\n $request[] = ''; $request[] = ''; $this->requests[] = implode("\r\n", $request); if ($this->currentRequestIndex === null) { $this->nextRequest(); } }
/** * The user agent the ForeignAPIRepo will use. */ public static function getUserAgent() { return Http::userAgent() . " ForeignAPIRepo/" . self::VERSION; }
/** * Take care of whatever is necessary to perform the URI request. * * @return Status */ public function execute() { global $wgTitle; wfProfileIn( __METHOD__ ); $this->content = ""; if ( strtoupper( $this->method ) == "HEAD" ) { $this->headersOnly = true; } if ( is_object( $wgTitle ) && !isset( $this->reqHeaders['Referer'] ) ) { $this->setReferer( wfExpandUrl( $wgTitle->getFullURL(), PROTO_CURRENT ) ); } $this->proxySetup(); // set up any proxy as needed if ( !$this->callback ) { $this->setCallback( array( $this, 'read' ) ); } if ( !isset( $this->reqHeaders['User-Agent'] ) ) { $this->setUserAgent( Http::userAgent() ); } wfProfileOut( __METHOD__ ); }
/** * Queue a purge operation * * @param $url string */ public function queuePurge($url) { $url = str_replace("\n", '', $url); $this->requests[] = "PURGE {$url} HTTP/1.0\r\n" . "Connection: Keep-Alive\r\n" . "Proxy-Connection: Keep-Alive\r\n" . "User-Agent: " . Http::userAgent() . ' ' . __CLASS__ . "\r\n\r\n"; if ($this->currentRequestIndex === null) { $this->nextRequest(); } }
/** * Take care of whatever is necessary to perform the URI request. * * @return Status */ public function execute() { global $wgTitle; $this->content = ""; if (strtoupper($this->method) == "HEAD") { $this->headersOnly = true; } if (is_array($this->postData)) { $this->postData = wfArrayToCGI($this->postData); } if (is_object($wgTitle) && !isset($this->reqHeaders['Referer'])) { $this->setReferer($wgTitle->getFullURL()); } if (!$this->noProxy) { $this->proxySetup(); } if (!$this->callback) { $this->setCallback(array($this, 'read')); } if (!isset($this->reqHeaders['User-Agent'])) { $this->setUserAgent(Http::userAgent()); } }
/** * Take care of whatever is necessary to perform the URI request. * * @return Status */ public function execute() { $this->content = ""; if (strtoupper($this->method) == "HEAD") { $this->headersOnly = true; } $this->proxySetup(); // set up any proxy as needed if (!$this->callback) { $this->setCallback([$this, 'read']); } if (!isset($this->reqHeaders['User-Agent'])) { $this->setUserAgent(Http::userAgent()); } }
function getCurlBaseOpts() { //I chose to return this as a function so it's easy to override. //TODO: probably this for all the junk I currently have stashed in the constructor. //...maybe. $opts = array(CURLOPT_URL => $this->url, CURLOPT_USERAGENT => Http::userAgent(), CURLOPT_HEADER => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_TIMEOUT => self::getGlobal('Timeout'), CURLOPT_FOLLOWLOCATION => 0, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_FORBID_REUSE => true, CURLOPT_POST => 1); // set proxy settings if necessary if (self::getGlobal('UseHTTPProxy')) { $opts[CURLOPT_HTTPPROXYTUNNEL] = 1; $opts[CURLOPT_PROXY] = self::getGlobal('HTTPProxy'); } return $opts; }
/** * set user agent * * @param string $userAgent */ public static function setUserAgent($userAgent) { self::$userAgent = $userAgent; }
static function getUserAgent() { return Http::userAgent(); }
/** * Take care of whatever is necessary to perform the URI request. * * @return Status */ public function execute() { global $wgTitle; $this->content = ""; if (strtoupper($this->method) == "HEAD") { $this->headersOnly = true; } if (is_object($wgTitle) && !isset($this->reqHeaders['Referer'])) { $this->setReferer(wfExpandUrl($wgTitle->getFullURL(), PROTO_CURRENT)); } if (!$this->noProxy) { $this->proxySetup(); } if (!$this->callback) { $this->setCallback(array($this, 'read')); } if (!isset($this->reqHeaders['User-Agent'])) { $this->setUserAgent(Http::userAgent()); } // @author macbre // pass Request ID to internal requests $this->setHeader(Wikia\Util\RequestId::REQUEST_HEADER_NAME, Wikia\Util\RequestId::instance()->getRequestId()); // Wikia change - begin - @author: wladek // Append extra headers for internal requests, currently only X-Request-Origin-Host if ($this->internalRequest) { $this->setHeader(Wikia\Util\RequestId::REQUEST_HEADER_ORIGIN_HOST, wfHostname()); } // Wikia change - end }
/** * @return string */ private static function getUserAgent() { return Http::userAgent() . ' MetricsReporting/' . METRICS_REPORTING_VERSION; }