*/
public static function request( $method, $url, $options = array() ) {
wfDebug( "HTTP: $method: $url\n" );
- wfProfileIn( __METHOD__ . "-$method" );
$options['method'] = strtoupper( $method );
if ( $status->isOK() ) {
$content = $req->getContent();
}
- wfProfileOut( __METHOD__ . "-$method" );
return $content;
}
* @return bool
*/
public static function isLocalURL( $url ) {
- global $wgCommandLineMode, $wgConf;
+ global $wgCommandLineMode, $wgLocalVirtualHosts, $wgConf;
if ( $wgCommandLineMode ) {
return false;
$host = $matches[1];
// Split up dotwise
$domainParts = explode( '.', $host );
- // Check if this domain or any superdomain is listed in $wgConf as a local virtual host
+ // Check if this domain or any superdomain is listed as a local virtual host
$domainParts = array_reverse( $domainParts );
$domain = '';
$domain = $domainPart . '.' . $domain;
}
- if ( $wgConf->isLocalVHost( $domain ) ) {
+ if ( in_array( $domain, $wgLocalVirtualHosts )
+ || $wgConf->isLocalVHost( $domain )
+ ) {
return true;
}
}
* @return Status
*/
public function execute() {
- wfProfileIn( __METHOD__ );
$this->content = "";
$this->setUserAgent( Http::userAgent() );
}
- wfProfileOut( __METHOD__ );
}
/**
* found in an array in the member variable headerList.
*/
protected function parseHeader() {
- wfProfileIn( __METHOD__ );
$lastname = "";
$this->parseCookies();
- wfProfileOut( __METHOD__ );
}
/**
* Parse the cookies in the response headers and store them in the cookie jar.
*/
protected function parseCookies() {
- wfProfileIn( __METHOD__ );
if ( !$this->cookieJar ) {
$this->cookieJar = new CookieJar;
}
}
- wfProfileOut( __METHOD__ );
}
/**
}
public function execute() {
- wfProfileIn( __METHOD__ );
parent::execute();
if ( !$this->status->isOK() ) {
- wfProfileOut( __METHOD__ );
return $this->status;
}
$curlHandle = curl_init( $this->url );
if ( !curl_setopt_array( $curlHandle, $this->curlOptions ) ) {
- wfProfileOut( __METHOD__ );
throw new MWException( "Error setting curl options." );
}
$this->parseHeader();
$this->setStatus();
- wfProfileOut( __METHOD__ );
-
return $this->status;
}
return false;
}
- if ( !defined( 'CURLOPT_REDIR_PROTOCOLS' ) ) {
+ $curlVersionInfo = curl_version();
+ if ( $curlVersionInfo['version_number'] < 0x071304 ) {
wfDebug( "Cannot follow redirects with libcurl < 7.19.4 due to CVE-2009-0037\n" );
return false;
}
}
public function execute() {
- wfProfileIn( __METHOD__ );
parent::execute();
if ( $fh === false ) {
$this->status->fatal( 'http-request-error' );
- wfProfileOut( __METHOD__ );
return $this->status;
}
if ( $result['timed_out'] ) {
$this->status->fatal( 'http-timed-out', $this->url );
- wfProfileOut( __METHOD__ );
return $this->status;
}
}
fclose( $fh );
- wfProfileOut( __METHOD__ );
-
return $this->status;
}
}