From: Roan Kattouw Date: Sun, 20 Nov 2011 17:45:18 +0000 (+0000) Subject: (bug 310720) Make Http::request() (and, by extension, get() and post() as well) accep... X-Git-Tag: 1.31.0-rc.0~26385 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22upgrade%22%2C%22reinstall=non%22%29%20.%20%22?a=commitdiff_plain;h=c5a18b323ad2ad35fc5a9566441fdb41763a8aab;p=lhc%2Fweb%2Fwiklou.git (bug 310720) Make Http::request() (and, by extension, get() and post() as well) accept a 'userAgent' option. Patch by Chad Horohoe --- diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index cbdcd7aece..f25a806d6c 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -29,6 +29,8 @@ class Http { * - 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() ) { @@ -40,6 +42,9 @@ class Http { } $req = MWHttpRequest::factory( $url, $options ); + if( isset( $options['userAgent'] ) ) { + $req->setUserAgent( $options['userAgent'] ); + } $status = $req->execute(); if ( $status->isOK() ) {