X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhttp%2FMWHttpRequest.php;h=b4ac9a750ef1fe93572db4f006874a8ed4a1aff1;hb=5853b3584c8f5b106f21a32e3c100eef710b69d6;hp=2cf532084c78810e9192b544ab1e806aa470e2a4;hpb=1c29f24dd5833ff2f990556291b5987b6b783e4e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/http/MWHttpRequest.php b/includes/http/MWHttpRequest.php index 2cf532084c..b4ac9a750e 100644 --- a/includes/http/MWHttpRequest.php +++ b/includes/http/MWHttpRequest.php @@ -91,7 +91,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface { * @throws Exception */ public function __construct( - $url, array $options = [], $caller = __METHOD__, $profiler = null + $url, array $options = [], $caller = __METHOD__, Profiler $profiler = null ) { global $wgHTTPTimeout, $wgHTTPConnectTimeout; @@ -129,6 +129,8 @@ abstract class MWHttpRequest implements LoggerAwareInterface { $this->setOriginalRequest( $options['originalRequest'] ); } + $this->setHeader( 'X-Request-Id', WebRequest::getRequestId() ); + $members = [ "postData", "proxy", "noProxy", "sslVerifyHost", "caInfo", "method", "followRedirects", "maxRedirects", "sslVerifyCert", "callback" ]; @@ -202,7 +204,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface { * @param array $args * @todo overload the args param */ - public function setData( $args ) { + public function setData( array $args ) { $this->postData = $args; } @@ -326,6 +328,17 @@ abstract class MWHttpRequest implements LoggerAwareInterface { * @throws InvalidArgumentException */ public function setCallback( $callback ) { + return $this->doSetCallback( $callback ); + } + + /** + * Worker function for setting callbacks. Calls can originate both internally and externally + * via setCallback). Defaults to the internal read callback if $callback is null. + * + * @param callable|null $callback + * @throws InvalidArgumentException + */ + protected function doSetCallback( $callback ) { if ( is_null( $callback ) ) { $callback = [ $this, 'read' ]; } elseif ( !is_callable( $callback ) ) { @@ -369,7 +382,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface { $this->proxySetup(); // set up any proxy as needed if ( !$this->callback ) { - $this->setCallback( null ); + $this->doSetCallback( null ); } if ( !isset( $this->reqHeaders['User-Agent'] ) ) { @@ -466,6 +479,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface { * request has been executed. Because some headers * (e.g. Set-Cookie) can appear more than once the, each value of * the associative array is an array of the values given. + * Header names are always in lowercase. * * @return array */ @@ -480,7 +494,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface { /** * Returns the value of the given response header. * - * @param string $header + * @param string $header case-insensitive * @return string|null */ public function getResponseHeader( $header ) { @@ -503,7 +517,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface { * * @param CookieJar $jar */ - public function setCookieJar( $jar ) { + public function setCookieJar( CookieJar $jar ) { $this->cookieJar = $jar; } @@ -529,7 +543,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface { * @param string $value * @param array $attr */ - public function setCookie( $name, $value, $attr = [] ) { + public function setCookie( $name, $value, array $attr = [] ) { if ( !$this->cookieJar ) { $this->cookieJar = new CookieJar; }