* @throws Exception
*/
public function __construct(
- $url, array $options = [], $caller = __METHOD__, $profiler = null
+ $url, array $options = [], $caller = __METHOD__, Profiler $profiler = null
) {
global $wgHTTPTimeout, $wgHTTPConnectTimeout;
$this->setOriginalRequest( $options['originalRequest'] );
}
+ $this->setHeader( 'X-Request-Id', WebRequest::getRequestId() );
+
$members = [ "postData", "proxy", "noProxy", "sslVerifyHost", "caInfo",
"method", "followRedirects", "maxRedirects", "sslVerifyCert", "callback" ];
* @param array $args
* @todo overload the args param
*/
- public function setData( $args ) {
+ public function setData( array $args ) {
$this->postData = $args;
}
* @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 ) ) {
$this->proxySetup(); // set up any proxy as needed
if ( !$this->callback ) {
- $this->setCallback( null );
+ $this->doSetCallback( null );
}
if ( !isset( $this->reqHeaders['User-Agent'] ) ) {
* 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
*/
/**
* Returns the value of the given response header.
*
- * @param string $header
+ * @param string $header case-insensitive
* @return string|null
*/
public function getResponseHeader( $header ) {
*
* @param CookieJar $jar
*/
- public function setCookieJar( $jar ) {
+ public function setCookieJar( CookieJar $jar ) {
$this->cookieJar = $jar;
}
* @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;
}