本文整理汇总了PHP中Http::userAgent方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::userAgent方法的具体用法?PHP Http::userAgent怎么用?PHP Http::userAgent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Http
的用法示例。
在下文中一共展示了Http::userAgent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: queuePurge
/**
* 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();
}
}
示例2: getUserAgent
/**
* The user agent the ForeignAPIRepo will use.
*/
public static function getUserAgent()
{
return Http::userAgent() . " ForeignAPIRepo/" . self::VERSION;
}
示例3: execute
/**
* 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__ );
}
示例4: queuePurge
/**
* 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();
}
}
示例5: execute
/**
* 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());
}
}
示例6: execute
/**
* 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());
}
}
示例7: getCurlBaseOpts
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;
}
示例8: setUserAgent
/**
* set user agent
*
* @param string $userAgent
*/
public static function setUserAgent($userAgent)
{
self::$userAgent = $userAgent;
}
示例9: getUserAgent
static function getUserAgent()
{
return Http::userAgent();
}
示例10: execute
/**
* 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
}
示例11: getUserAgent
/**
* @return string
*/
private static function getUserAgent()
{
return Http::userAgent() . ' MetricsReporting/' . METRICS_REPORTING_VERSION;
}