当前位置: 首页>>代码示例>>PHP>>正文


PHP MWHttpRequest::factory方法代码示例

本文整理汇总了PHP中MWHttpRequest::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP MWHttpRequest::factory方法的具体用法?PHP MWHttpRequest::factory怎么用?PHP MWHttpRequest::factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MWHttpRequest的用法示例。


在下文中一共展示了MWHttpRequest::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getData

	public function getData () {

		// Crazy workaround for HttpRequest not accepting user options
		$req = MWHttpRequest::factory( $this->summaryDataURL, array ('method' => "GET", 'timeout' => 'default') );
		$req->setHeader("http-x-license-key", $this->licenceKey);
		$status = $req->execute();
		$response = $req->getContent();
		$data = array();

		if ($response) {
			// chop up xml
			$xml = simplexml_load_string($response);
			$data = array();
			foreach ($xml->threshold_value as $node) {
				$label = (string)$node['name'];

				// just grab the time from the first field since we are rounding to the nearest hour anyway
				if (empty($data['Time'])) {
					$time = (string)$node['end_time'];
					$date = strtotime($time);  // raw mysql date format should parse ok
					$data['Time'] = $date;
				}
				// we only want to use some of the fields returned from new relic
				if (in_array($label, array('Errors', 'Response Time', 'Throughput')))
					$data[$label] = (string)$node['metric_value'];
			}
		} else {
//			print_pre("null response from newrelic");
		}
		return $data;
	}
开发者ID:schwarer2006,项目名称:wikia,代码行数:31,代码来源:ResponsetimeNewrelic.php

示例2: getInterfaceObjectFromType

 protected function getInterfaceObjectFromType($type)
 {
     wfProfileIn(__METHOD__);
     $apiUrl = $this->getApiUrl();
     if (empty($this->videoId)) {
         throw new EmptyResponseException($apiUrl);
     }
     $memcKey = wfMemcKey(static::$CACHE_KEY, $apiUrl, static::$CACHE_KEY_VERSION);
     $processedResponse = F::app()->wg->memc->get($memcKey);
     if (empty($processedResponse)) {
         $req = MWHttpRequest::factory($apiUrl, array('noProxy' => true));
         $req->setHeader('User-Agent', self::$REQUEST_USER_AGENT);
         $status = $req->execute();
         if ($status->isOK()) {
             $response = $req->getContent();
             $this->response = $response;
             // Only for migration purposes
             if (empty($response)) {
                 throw new EmptyResponseException($apiUrl);
             } else {
                 if ($req->getStatus() == 301) {
                     throw new VideoNotFoundException($req->getStatus(), $this->videoId . ' Moved Permanently.', $apiUrl);
                 }
             }
         } else {
             $this->checkForResponseErrors($req->status, $req->getContent(), $apiUrl);
         }
         $processedResponse = $this->processResponse($response, $type);
         F::app()->wg->memc->set($memcKey, $processedResponse, static::$CACHE_EXPIRY);
     }
     wfProfileOut(__METHOD__);
     return $processedResponse;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:33,代码来源:GamestarApiWrapper.class.php

示例3: streamAppleTouch

function streamAppleTouch()
{
    global $wgAppleTouchIcon;
    wfResetOutputBuffers();
    if ($wgAppleTouchIcon === false) {
        # That's not very helpful, that's where we are already
        header('HTTP/1.1 404 Not Found');
        faviconShowError('$wgAppleTouchIcon is configured incorrectly, ' . 'it must be set to something other than false \\n');
        return;
    }
    $req = RequestContext::getMain()->getRequest();
    if ($req->getHeader('X-Favicon-Loop') !== false) {
        header('HTTP/1.1 500 Internal Server Error');
        faviconShowError('Proxy forwarding loop detected');
        return;
    }
    $url = wfExpandUrl($wgAppleTouchIcon, PROTO_CANONICAL);
    $client = MWHttpRequest::factory($url);
    $client->setHeader('X-Favicon-Loop', '1');
    $status = $client->execute();
    if (!$status->isOK()) {
        header('HTTP/1.1 500 Internal Server Error');
        faviconShowError("Failed to fetch URL \"{$url}\"");
        return;
    }
    $content = $client->getContent();
    header('Content-Length: ' . strlen($content));
    header('Content-Type: ' . $client->getResponseHeader('Content-Type'));
    header('Cache-Control: public');
    header('Expires: ' . gmdate('r', time() + 86400));
    echo $content;
}
开发者ID:nomoa,项目名称:operations-mediawiki-config,代码行数:32,代码来源:touch.php

示例4: passCaptcha

 /**
  * Check, if the user solved the captcha.
  *
  * Based on reference implementation:
  * https://github.com/google/recaptcha#php
  *
  * @return boolean
  */
 function passCaptcha()
 {
     global $wgRequest, $wgReCaptchaSecretKey, $wgReCaptchaSendRemoteIP;
     $url = 'https://www.google.com/recaptcha/api/siteverify';
     // Build data to append to request
     $data = array('secret' => $wgReCaptchaSecretKey, 'response' => $wgRequest->getVal('g-recaptcha-response'));
     if ($wgReCaptchaSendRemoteIP) {
         $data['remoteip'] = $wgRequest->getIP();
     }
     $url = wfAppendQuery($url, $data);
     $request = MWHttpRequest::factory($url, array('method' => 'GET'));
     $status = $request->execute();
     if (!$status->isOK()) {
         $this->error = 'http';
         $this->logStatusError($status);
         return false;
     }
     $response = FormatJson::decode($request->getContent(), true);
     if (!$response) {
         $this->error = 'json';
         $this->logStatusError($this->error);
         return false;
     }
     if (isset($response['error-codes'])) {
         $this->error = 'recaptcha-api';
         $this->logCheckError($response['error-codes']);
         return false;
     }
     return $response['success'];
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:38,代码来源:ReCaptchaNoCaptcha.class.php

示例5: checkContactLink

 protected function checkContactLink($name, $url, &$countOk)
 {
     global $wgVersion;
     $ok = false;
     if (Sanitizer::validateEmail($url)) {
         $ok = true;
         // assume OK
     } else {
         $bits = wfParseUrl($url);
         if ($bits && isset($bits['scheme'])) {
             if ($bits['scheme'] == 'mailto') {
                 $ok = true;
                 // assume OK
             } elseif (in_array($bits['scheme'], array('http', 'https'))) {
                 $req = MWHttpRequest::factory($url, array('method' => 'GET', 'timeout' => 8, 'sslVerifyHost' => false, 'sslVerifyCert' => false));
                 $req->setUserAgent("MediaWiki {$wgVersion}, CheckCongressLinks Checker");
                 $ok = $req->execute()->isOK();
             }
         }
     }
     if ($ok) {
         ++$countOk;
     } else {
         $this->output("Broken: [{$name}] [{$url}]\n");
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:26,代码来源:checkContacts.php

示例6: testApiLoginGotCookie

 /**
  * @group Broken
  */
 public function testApiLoginGotCookie()
 {
     $this->markTestIncomplete("The server can't do external HTTP requests, " . "and the internal one won't give cookies");
     global $wgServer, $wgScriptPath;
     if (!isset($wgServer)) {
         $this->markTestIncomplete('This test needs $wgServer to be set in LocalSettings.php');
     }
     $user = self::$users['sysop'];
     $req = MWHttpRequest::factory(self::$apiUrl . "?action=login&format=xml", array("method" => "POST", "postData" => array("lgname" => $user->username, "lgpassword" => $user->password)), __METHOD__);
     $req->execute();
     libxml_use_internal_errors(true);
     $sxe = simplexml_load_string($req->getContent());
     $this->assertNotInternalType("bool", $sxe);
     $this->assertThat($sxe, $this->isInstanceOf("SimpleXMLElement"));
     $this->assertNotInternalType("null", $sxe->login[0]);
     $a = $sxe->login[0]->attributes()->result[0];
     $this->assertEquals(' result="NeedToken"', $a->asXML());
     $token = (string) $sxe->login[0]->attributes()->token;
     $req->setData(array("lgtoken" => $token, "lgname" => $user->username, "lgpassword" => $user->password));
     $req->execute();
     $cj = $req->getCookieJar();
     $serverName = parse_url($wgServer, PHP_URL_HOST);
     $this->assertNotEquals(false, $serverName);
     $serializedCookie = $cj->serializeToHttpRequest($wgScriptPath, $serverName);
     $this->assertNotEquals('', $serializedCookie);
     $this->assertRegexp('/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . $user->userName . '; .*Token=/', $serializedCookie);
 }
开发者ID:lourinaldi,项目名称:mediawiki,代码行数:30,代码来源:ApiLoginTest.php

示例7: getImage

 /**
  * getImage method
  *
  */
 public function getImage()
 {
     $this->wf->profileIn(__METHOD__);
     if ($this->wg->User->isLoggedIn()) {
         # make proper thumb path: c/central/images/thumb/....
         $path = sprintf("%s/%s/images", substr($this->wg->DBname, 0, 1), $this->wg->DBname);
         # take thumb request from request
         $img = $this->getVal('image');
         if (preg_match('/^(\\/?)thumb\\//', $img)) {
             # build proper thumb url for thumbnailer
             $thumb_url = sprintf("%s/%s/%s", $this->wg->ThumbnailerService, $path, $img);
             # call thumbnailer
             $options = array('method' => 'GET', 'timeout' => 'default', 'noProxy' => 1);
             $thumb_request = MWHttpRequest::factory($thumb_url, $options);
             $status = $thumb_request->execute();
             $headers = $thumb_request->getResponseHeaders();
             if ($status->isOK()) {
                 if (!empty($headers)) {
                     foreach ($headers as $header_name => $header_value) {
                         if (is_array($header_value)) {
                             list($value) = $header_value;
                         } else {
                             $value = $header_value;
                         }
                         header(sprintf("%s: %s", $header_name, $value));
                     }
                 }
                 echo $thumb_request->getContent();
             } else {
                 $this->wf->debug("Cannot generate auth thumb");
                 $this->_access_forbidden('img-auth-accessdenied', 'img-auth-nofile', $img);
             }
         } else {
             # serve original image
             $filename = realpath(sprintf("%s/%s", $this->wg->UploadDirectory, $img));
             $stat = @stat($filename);
             if ($stat) {
                 $this->wf->ResetOutputBuffers();
                 $fileinfo = finfo_open(FILEINFO_MIME_TYPE);
                 $imageType = finfo_file($fileinfo, $filename);
                 header(sprintf("Content-Disposition: inline;filename*=utf-8'%s'%s", $this->wg->ContLanguageCode, urlencode(basename($filename))));
                 header(sprintf("Content-Type: %s", $imageType));
                 header(sprintf("Content-Length: %d" . $stat['size']));
                 readfile($filename);
             } else {
                 $this->_access_forbidden('img-auth-accessdenied', 'img-auth-nopathinfo', $img);
             }
         }
     } else {
         $this->_access_forbidden('img-auth-accessdenied', 'img-auth-public', '');
     }
     $this->wf->profileOut(__METHOD__);
     exit;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:58,代码来源:AuthImageSpecialPageController.class.php

示例8: request

 /**
  * Perform an HTTP request
  *
  * @param $method String: HTTP method. Usually GET/POST
  * @param $url String: full URL to act on. If protocol-relative, will be expanded to an http:// URL
  * @param $options Array: options to pass to MWHttpRequest object.
  *	Possible keys for the array:
  *    - timeout             Timeout length in seconds
  *    - postData            An array of key-value pairs or a url-encoded form data
  *    - proxy               The proxy to use.
  *                          Will use $wgHTTPProxy (if set) otherwise.
  *    - noProxy             Override $wgHTTPProxy (if set) and don't use any proxy at all.
  *    - sslVerifyHost       (curl only) Verify hostname against certificate
  *    - sslVerifyCert       (curl only) Verify SSL certificate
  *    - caInfo              (curl only) Provide CA information
  *    - maxRedirects        Maximum number of redirects to follow (defaults to 5)
  *    - followRedirects     Whether to follow redirects (defaults to false).
  *		                    Note: this should only be used when the target URL is trusted,
  *		                    to avoid attacks on intranet services accessible by HTTP.
  *    - userAgent           A user agent, if you want to override the default
  *                          MediaWiki/$wgVersion
  *    - headers             Additional headers for request
  *    - returnInstance      If set the method will return MWHttpRequest instance instead of string|boolean
  * @return Mixed: (bool)false on failure or a string on success or MWHttpRequest instance if returnInstance option is set
  */
 public static function request($method, $url, $options = array())
 {
     $fname = __METHOD__ . '::' . $method;
     wfProfileIn($fname);
     wfDebug("HTTP: {$method}: {$url}\n");
     $options['method'] = strtoupper($method);
     if (!isset($options['timeout'])) {
         $options['timeout'] = 'default';
     }
     $req = MWHttpRequest::factory($url, $options);
     // Wikia change - @author: suchy - begin
     if (isset($options['headers']) && is_array($options['headers'])) {
         foreach ($options['headers'] as $name => $value) {
             $req->setHeader($name, $value);
         }
     }
     // Wikia change - end
     if (isset($options['userAgent'])) {
         $req->setUserAgent($options['userAgent']);
     }
     // Wikia change - @author: mech - begin
     $requestTime = microtime(true);
     // Wikia change - end
     $status = $req->execute();
     // Wikia change - @author: mech - begin
     // log all the requests we make
     $caller = wfGetCallerClassMethod([__CLASS__, 'Hooks', 'ApiService', 'Solarium_Client', 'Solarium_Client_Adapter_Curl']);
     $isOk = $status->isOK();
     if (class_exists('Wikia\\Logger\\WikiaLogger')) {
         $requestTime = (int) ((microtime(true) - $requestTime) * 1000.0);
         $backendTime = $req->getResponseHeader('x-backend-response-time') ?: 0;
         $params = ['statusCode' => $req->getStatus(), 'reqMethod' => $method, 'reqUrl' => $url, 'caller' => $caller, 'isOk' => $isOk, 'requestTimeMS' => $requestTime, 'backendTimeMS' => intval(1000 * $backendTime)];
         if (!$isOk) {
             $params['statusMessage'] = $status->getMessage();
         }
         \Wikia\Logger\WikiaLogger::instance()->debug('Http request', $params);
     }
     // Wikia change - @author: nAndy - begin
     // Introduced new returnInstance options to return MWHttpRequest instance instead of string-bool mix
     if (!empty($options['returnInstance'])) {
         $ret = $req;
     } else {
         if ($isOk) {
             $ret = $req->getContent();
             // Wikia change - end
         } else {
             $ret = false;
         }
     }
     wfProfileOut($fname);
     return $ret;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:77,代码来源:HttpFunctions.php

示例9: makeRequest

 public function makeRequest($url, $method = 'POST')
 {
     $options = array('method' => $method);
     if ($this->followRedirects) {
         $options['followRedirects'] = true;
         $this->followRedirects = false;
         # Reset the flag
     }
     $req = MWHttpRequest::factory($url, $options);
     $req->setUserAgent($this->userAgent);
     $req->setCookieJar($this->cookie_jar);
     return $req;
 }
开发者ID:ATCARES,项目名称:mediawiki-moderation,代码行数:13,代码来源:ModerationTestsuiteHTTP.php

示例10: importVideosForKeyphrase

 protected function importVideosForKeyphrase($keyword, $params = array())
 {
     wfProfileIn(__METHOD__);
     $addlCategories = !empty($params['addlCategories']) ? $params['addlCategories'] : array();
     $debug = !empty($params['debug']);
     $startDate = !empty($params['startDate']) ? $params['startDate'] : '';
     $endDate = !empty($params['endDate']) ? $params['endDate'] : '';
     $articlesCreated = 0;
     $page = 1;
     do {
         $numVideos = 0;
         // connect to provider API
         $url = $this->initFeedUrl($keyword, $startDate, $endDate, $page++);
         print "Connecting to {$url}...\n";
         $req = MWHttpRequest::factory($url);
         $status = $req->execute();
         if ($status->isOK()) {
             $response = $req->getContent();
         } else {
             print "ERROR: problem downloading content!\n";
             wfProfileOut(__METHOD__);
             return 0;
         }
         // parse response
         $videos = json_decode($response, true);
         $numVideos = sizeof($videos['videos']);
         print "Found {$numVideos} videos...\n";
         for ($i = 0; $i < $numVideos; $i++) {
             $clipData = array();
             $video = $videos['videos'][$i];
             $clipData['clipTitle'] = trim($video['title']);
             $clipData['videoId'] = $video['guid'];
             $clipData['thumbnail'] = $video['image'];
             $clipData['duration'] = $video['duration'];
             $clipData['published'] = $video['date'];
             $clipData['category'] = $video['category_name'];
             $clipData['keywords'] = trim($video['tags']);
             $clipData['description'] = trim($video['description']);
             $clipData['aspectRatio'] = $video['aspect_ratio'];
             $msg = '';
             $createParams = array('addlCategories' => $addlCategories, 'debug' => $debug);
             $articlesCreated += $this->createVideo($clipData, $msg, $createParams);
             if ($msg) {
                 print "ERROR: {$msg}\n";
             }
         }
     } while ($numVideos == self::API_PAGE_SIZE);
     wfProfileOut(__METHOD__);
     return $articlesCreated;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:50,代码来源:RealgravityFeedIngester.class.php

示例11: request

 /**
  * Perform an HTTP request
  *
  * @param $method String: HTTP method. Usually GET/POST
  * @param $url String: full URL to act on. If protocol-relative, will be expanded to an http:// URL
  * @param $options Array: options to pass to MWHttpRequest object.
  *	Possible keys for the array:
  *    - timeout             Timeout length in seconds
  *    - postData            An array of key-value pairs or a url-encoded form data
  *    - proxy               The proxy to use.
  *                          Otherwise it will use $wgHTTPProxy (if set)
  *                          Otherwise it will use the environment variable "http_proxy" (if set)
  *    - noProxy             Don't use any proxy at all. Takes precedence over proxy value(s).
  *    - sslVerifyHost       (curl only) Verify hostname against certificate
  *    - sslVerifyCert       (curl only) Verify SSL certificate
  *    - caInfo              (curl only) Provide CA information
  *    - maxRedirects        Maximum number of redirects to follow (defaults to 5)
  *    - followRedirects     Whether to follow redirects (defaults to false).
  *		                    Note: this should only be used when the target URL is trusted,
  *		                    to avoid attacks on intranet services accessible by HTTP.
  *    - userAgent           A user agent, if you want to override the default
  *                          MediaWiki/$wgVersion
  * @return Mixed: (bool)false on failure or a string on success
  */
 public static function request($method, $url, $options = array())
 {
     wfDebug("HTTP: {$method}: {$url}\n");
     $options['method'] = strtoupper($method);
     if (!isset($options['timeout'])) {
         $options['timeout'] = 'default';
     }
     $req = MWHttpRequest::factory($url, $options);
     $status = $req->execute();
     if ($status->isOK()) {
         return $req->getContent();
     } else {
         return false;
     }
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:39,代码来源:HttpFunctions.php

示例12: requestParsoid

 protected function requestParsoid($method, $title, $params)
 {
     global $wgVisualEditorParsoidURL, $wgVisualEditorParsoidTimeout, $wgVisualEditorParsoidForwardCookies;
     $url = $wgVisualEditorParsoidURL . '/' . urlencode($this->getApiSource()) . '/' . urlencode($title->getPrefixedDBkey());
     $data = array_merge($this->getProxyConf(), array('method' => $method, 'timeout' => $wgVisualEditorParsoidTimeout));
     if ($method === 'POST') {
         $data['postData'] = $params;
     } else {
         $url = wfAppendQuery($url, $params);
     }
     $req = MWHttpRequest::factory($url, $data);
     // Forward cookies, but only if configured to do so and if there are read restrictions
     if ($wgVisualEditorParsoidForwardCookies && !User::isEveryoneAllowed('read')) {
         $req->setHeader('Cookie', $this->getRequest()->getHeader('Cookie'));
     }
     $status = $req->execute();
     if ($status->isOK()) {
         // Pass thru performance data from Parsoid to the client, unless the response was
         // served directly from Varnish, in  which case discard the value of the XPP header
         // and use it to declare the cache hit instead.
         $xCache = $req->getResponseHeader('X-Cache');
         if (is_string($xCache) && strpos(strtolower($xCache), 'hit') !== false) {
             $xpp = 'cached-response=true';
             $hit = true;
         } else {
             $xpp = $req->getResponseHeader('X-Parsoid-Performance');
             $hit = false;
         }
         WikiaLogger::instance()->debug('ApiVisualEditor', array('hit' => $hit, 'method' => $method, 'url' => $url));
         if ($xpp !== null) {
             $resp = $this->getRequest()->response();
             $resp->header('X-Parsoid-Performance: ' . $xpp);
         }
     } elseif ($status->isGood()) {
         $this->dieUsage($req->getContent(), 'parsoidserver-http-' . $req->getStatus());
     } elseif ($errors = $status->getErrorsByType('error')) {
         $error = $errors[0];
         $code = $error['message'];
         if (count($error['params'])) {
             $message = $error['params'][0];
         } else {
             $message = 'MWHttpRequest error';
         }
         $this->dieUsage($message, 'parsoidserver-' . $code);
     }
     // TODO pass through X-Parsoid-Performance header, merge with getHTML above
     return $req->getContent();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:48,代码来源:ApiVisualEditor.php

示例13: request

 /**
  * Perform an HTTP request
  *
  * @param string $method HTTP method. Usually GET/POST
  * @param string $url full URL to act on. If protocol-relative, will be expanded to an http:// URL
  * @param array $options options to pass to MWHttpRequest object.
  *	Possible keys for the array:
  *    - timeout             Timeout length in seconds
  *    - postData            An array of key-value pairs or a url-encoded form data
  *    - proxy               The proxy to use.
  *                          Otherwise it will use $wgHTTPProxy (if set)
  *                          Otherwise it will use the environment variable "http_proxy" (if set)
  *    - noProxy             Don't use any proxy at all. Takes precedence over proxy value(s).
  *    - sslVerifyHost       (curl only) Verify hostname against certificate
  *    - sslVerifyCert       (curl only) Verify SSL certificate
  *    - caInfo              (curl only) Provide CA information
  *    - maxRedirects        Maximum number of redirects to follow (defaults to 5)
  *    - followRedirects     Whether to follow redirects (defaults to false).
  *		                    Note: this should only be used when the target URL is trusted,
  *		                    to avoid attacks on intranet services accessible by HTTP.
  *    - userAgent           A user agent, if you want to override the default
  *                          MediaWiki/$wgVersion
  * @return Mixed: (bool)false on failure or a string on success
  */
 public static function request($method, $url, $options = array())
 {
     wfDebug("HTTP: {$method}: {$url}\n");
     wfProfileIn(__METHOD__ . "-{$method}");
     $options['method'] = strtoupper($method);
     if (!isset($options['timeout'])) {
         $options['timeout'] = 'default';
     }
     $req = MWHttpRequest::factory($url, $options);
     $status = $req->execute();
     $content = false;
     if ($status->isOK()) {
         $content = $req->getContent();
     }
     wfProfileOut(__METHOD__ . "-{$method}");
     return $content;
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:41,代码来源:HttpFunctions.php

示例14: hitUrl

 public function hitUrl($zip, $attempt = 0)
 {
     $url = $this->makeUrl($zip);
     //$this->output( "*Trying to hit $url\n" );
     $req = MWHttpRequest::factory($url, array('method' => 'GET', 'timeout' => 2, 'sslVerifyHost' => false, 'sslVerifyCert' => false));
     if ($req->execute()->isOK()) {
         $this->isOK++;
     } else {
         sleep(2);
         $attempt++;
         if ($attempt < 3) {
             $this->hitUrl($zip, $attempt);
         } else {
             $this->isBad++;
         }
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:17,代码来源:populateCache.php

示例15: request

 /**
  * Perform an HTTP request
  *
  * @param string $method HTTP method. Usually GET/POST
  * @param string $url Full URL to act on. If protocol-relative, will be expanded to an http:// URL
  * @param array $options Options to pass to MWHttpRequest object.
  *	Possible keys for the array:
  *    - timeout             Timeout length in seconds
  *    - connectTimeout      Timeout for connection, in seconds (curl only)
  *    - postData            An array of key-value pairs or a url-encoded form data
  *    - proxy               The proxy to use.
  *                          Otherwise it will use $wgHTTPProxy (if set)
  *                          Otherwise it will use the environment variable "http_proxy" (if set)
  *    - noProxy             Don't use any proxy at all. Takes precedence over proxy value(s).
  *    - sslVerifyHost       Verify hostname against certificate
  *    - sslVerifyCert       Verify SSL certificate
  *    - caInfo              Provide CA information
  *    - maxRedirects        Maximum number of redirects to follow (defaults to 5)
  *    - followRedirects     Whether to follow redirects (defaults to false).
  *		                    Note: this should only be used when the target URL is trusted,
  *		                    to avoid attacks on intranet services accessible by HTTP.
  *    - userAgent           A user agent, if you want to override the default
  *                          MediaWiki/$wgVersion
  * @param string $caller The method making this request, for profiling
  * @return string|bool (bool)false on failure or a string on success
  */
 public static function request($method, $url, $options = array(), $caller = __METHOD__)
 {
     wfDebug("HTTP: {$method}: {$url}\n");
     $options['method'] = strtoupper($method);
     if (!isset($options['timeout'])) {
         $options['timeout'] = 'default';
     }
     if (!isset($options['connectTimeout'])) {
         $options['connectTimeout'] = 'default';
     }
     $req = MWHttpRequest::factory($url, $options, $caller);
     $status = $req->execute();
     $content = false;
     if ($status->isOK()) {
         $content = $req->getContent();
     }
     return $content;
 }
开发者ID:nanasess,项目名称:mediawiki,代码行数:44,代码来源:HttpFunctions.php


注:本文中的MWHttpRequest::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。