dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add parser method to call parser functions
[lhc/web/wiklou.git]
/
includes
/
HttpFunctions.php
diff --git
a/includes/HttpFunctions.php
b/includes/HttpFunctions.php
index
27b1749
..
9e280db
100644
(file)
--- a/
includes/HttpFunctions.php
+++ b/
includes/HttpFunctions.php
@@
-58,6
+58,8
@@
class Http {
*/
public static function request( $method, $url, $options = array() ) {
wfDebug( "HTTP: $method: $url\n" );
*/
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['method'] = strtoupper( $method );
if ( !isset( $options['timeout'] ) ) {
@@
-67,11
+69,12
@@
class Http {
$req = MWHttpRequest::factory( $url, $options );
$status = $req->execute();
$req = MWHttpRequest::factory( $url, $options );
$status = $req->execute();
+ $content = false;
if ( $status->isOK() ) {
if ( $status->isOK() ) {
- return $req->getContent();
- } else {
- return false;
+ $content = $req->getContent();
}
}
+ wfProfileOut( __METHOD__ . "-$method" );
+ return $content;
}
/**
}
/**
@@
-335,7
+338,7
@@
class MWHttpRequest {
}
/**
}
/**
- * Set the refer
e
rer header
+ * Set the referrer header
*/
public function setReferer( $url ) {
$this->setHeader( 'Referer', $url );
*/
public function setReferer( $url ) {
$this->setHeader( 'Referer', $url );
@@
-427,6
+430,8
@@
class MWHttpRequest {
public function execute() {
global $wgTitle;
public function execute() {
global $wgTitle;
+ wfProfileIn( __METHOD__ );
+
$this->content = "";
if ( strtoupper( $this->method ) == "HEAD" ) {
$this->content = "";
if ( strtoupper( $this->method ) == "HEAD" ) {
@@
-446,14
+451,18
@@
class MWHttpRequest {
if ( !isset( $this->reqHeaders['User-Agent'] ) ) {
$this->setUserAgent( Http::userAgent() );
}
if ( !isset( $this->reqHeaders['User-Agent'] ) ) {
$this->setUserAgent( Http::userAgent() );
}
+
+ wfProfileOut( __METHOD__ );
}
/**
* Parses the headers, including the HTTP status code and any
}
/**
* Parses the headers, including the HTTP status code and any
- * Set-Cookie headers. This function expect
e
s the headers to be
+ * Set-Cookie headers. This function expects the headers to be
* found in an array in the member variable headerList.
*/
protected function parseHeader() {
* found in an array in the member variable headerList.
*/
protected function parseHeader() {
+ wfProfileIn( __METHOD__ );
+
$lastname = "";
foreach ( $this->headerList as $header ) {
$lastname = "";
foreach ( $this->headerList as $header ) {
@@
-470,6
+479,8
@@
class MWHttpRequest {
}
$this->parseCookies();
}
$this->parseCookies();
+
+ wfProfileOut( __METHOD__ );
}
/**
}
/**
@@
-603,6
+614,8
@@
class MWHttpRequest {
* Parse the cookies in the response headers and store them in the cookie jar.
*/
protected function parseCookies() {
* 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;
}
if ( !$this->cookieJar ) {
$this->cookieJar = new CookieJar;
}
@@
-613,6
+626,8
@@
class MWHttpRequest {
$this->cookieJar->parseCookieResponseHeader( $cookie, $url['host'] );
}
}
$this->cookieJar->parseCookieResponseHeader( $cookie, $url['host'] );
}
}
+
+ wfProfileOut( __METHOD__ );
}
/**
}
/**
@@
-700,9
+715,12
@@
class CurlHttpRequest extends MWHttpRequest {
}
public function execute() {
}
public function execute() {
+ wfProfileIn( __METHOD__ );
+
parent::execute();
if ( !$this->status->isOK() ) {
parent::execute();
if ( !$this->status->isOK() ) {
+ wfProfileOut( __METHOD__ );
return $this->status;
}
return $this->status;
}
@@
-746,6
+764,7
@@
class CurlHttpRequest extends MWHttpRequest {
$curlHandle = curl_init( $this->url );
if ( !curl_setopt_array( $curlHandle, $this->curlOptions ) ) {
$curlHandle = curl_init( $this->url );
if ( !curl_setopt_array( $curlHandle, $this->curlOptions ) ) {
+ wfProfileOut( __METHOD__ );
throw new MWException( "Error setting curl options." );
}
throw new MWException( "Error setting curl options." );
}
@@
-777,6
+796,8
@@
class CurlHttpRequest extends MWHttpRequest {
$this->parseHeader();
$this->setStatus();
$this->parseHeader();
$this->setStatus();
+ wfProfileOut( __METHOD__ );
+
return $this->status;
}
return $this->status;
}
@@
-811,6
+832,8
@@
class PhpHttpRequest extends MWHttpRequest {
}
public function execute() {
}
public function execute() {
+ wfProfileIn( __METHOD__ );
+
parent::execute();
if ( is_array( $this->postData ) ) {
parent::execute();
if ( is_array( $this->postData ) ) {
@@
-903,11
+926,13
@@
class PhpHttpRequest extends MWHttpRequest {
if ( $fh === false ) {
$this->status->fatal( 'http-request-error' );
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 );
return $this->status;
}
if ( $result['timed_out'] ) {
$this->status->fatal( 'http-timed-out', $this->url );
+ wfProfileOut( __METHOD__ );
return $this->status;
}
return $this->status;
}
@@
-930,6
+955,8
@@
class PhpHttpRequest extends MWHttpRequest {
}
fclose( $fh );
}
fclose( $fh );
+ wfProfileOut( __METHOD__ );
+
return $this->status;
}
}
return $this->status;
}
}