r103765 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103764‎ | r103765 | r103766 >
Date:17:45, 20 November 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
(bug 310720) Make Http::request() (and, by extension, get() and post() as well) accept a 'userAgent' option. Patch by Chad Horohoe
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HttpFunctions.php
@@ -29,6 +29,8 @@
3030 * - followRedirects Whether to follow redirects (defaults to false).
3131 * Note: this should only be used when the target URL is trusted,
3232 * to avoid attacks on intranet services accessible by HTTP.
 33+ * - userAgent A user agent, if you want to override the default
 34+ * MediaWiki/$wgVersion
3335 * @return Mixed: (bool)false on failure or a string on success
3436 */
3537 public static function request( $method, $url, $options = array() ) {
@@ -40,6 +42,9 @@
4143 }
4244
4345 $req = MWHttpRequest::factory( $url, $options );
 46+ if( isset( $options['userAgent'] ) ) {
 47+ $req->setUserAgent( $options['userAgent'] );
 48+ }
4449 $status = $req->execute();
4550
4651 if ( $status->isOK() ) {

Comments

#Comment by Catrope (talk | contribs)   19:29, 20 November 2011

I meant bug 31072

#Comment by Olivier Beaton (talk | contribs)   15:06, 9 December 2011

thanks!

Status & tagging log