Last modified: 2011-11-20 17:53:00 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T33072, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 31072 - Http::get should accept user-agent option
Http::get should accept user-agent option
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Unprioritized enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-21 14:53 UTC by Olivier Finlay Beaton
Modified: 2011-11-20 17:53 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Implement UA at Http::request() level (947 bytes, patch)
2011-09-22 21:11 UTC, Chad H.
Details

Description Olivier Finlay Beaton 2011-09-21 14:53:04 UTC
for any extension that uses Http::get a common task is setting the user-agent, which means they have to use the request object instead.  Really $options should include the user-agent string
Comment 1 Brion Vibber 2011-09-21 19:03:15 UTC
Most sensible thing may be to just accept a 'headers' key with a map of HTTP headers to set.

Thus:

$foo = Http::get($url, array(
  'followRedirects' => false,
  'postData' => array(
    'foo' => 'bar',
    'baz' => 'quux',
  ),
  'headers' => array(
    'User-Agent': 'my special extension',
    'Accept': 'application/x-something',
  )
);
Comment 2 Olivier Finlay Beaton 2011-09-22 17:34:55 UTC
Doing some compat testing and I found out that this is actually lost functionality.  Here's what Http::get looked like in 1.15

public static function get( $url, $timeout = 'default', $opts = array() ) {
  return Http::request( "GET", $url, $timeout, $opts );

public static function request( $method, $url, $timeout = 'default', $curlOptions = array() ) {


and $curlOptions can accept CURLOPT_USERAGENT
Comment 3 Daniel Friesen 2011-09-22 21:05:28 UTC
...reviving that would be a bit of a hack though. CURL isn't the only thing we support.
Comment 4 Chad H. 2011-09-22 21:11:01 UTC
Created attachment 9087 [details]
Implement UA at Http::request() level

I'm not so sure it's that hard or that hacky.
Comment 5 Roan Kattouw 2011-11-20 17:53:00 UTC
Patch applied in r103765

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links