Skip Menu |

This queue is for tickets about the MediaWiki-API CPAN distribution.

Report information
The Basics
Id: 52785
Status: resolved
Priority: 0/
Queue: MediaWiki-API

People
Owner: Nobody in particular
Requestors: andy.jenkinson [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 0.05
  • 0.06
  • 0.07
  • 0.08
  • 0.09
  • 0.10
  • 0.11
  • 0.12
  • 0.13
  • 0.14
  • 0.16
  • 0.17
  • 0.18
  • 0.19
  • 0.20
  • 0.21
  • 0.22
  • 0.23
  • 0.24
  • 0.25
  • 0.27
  • 0.28
Fixed in: (no value)



Subject: Request: proxy support
It would be very useful to add proxy support, currently not present. I have attached a patch to enable this feature in line with its implementation in WWW::Mechanize. That is, the MediaWiki::API constructor will call 'env_proxy' on the underlying LWP::UserAgent object unless instructed not to by a 'noproxy' config parameter.
Subject: API.pm.noproxy.patch
--- API.pm 2009-12-15 12:08:50.000000000 +0000 +++ API.pm.new 2009-12-15 12:11:40.000000000 +0000 @@ -112,6 +112,8 @@ =item * max_lag_retries = Integer value; The number of retries to send an API request if the server has reported a lag more than the value of max_lag. If the maximum retries is reached, an error is returned. Setting this to a negative value like -1 will mean the request is resent until the servers max_lag is below the threshold or another error occurs. Defaults to 4. +=item * noproxy = Disable use of any proxy set in the environment. + =back An example for the on_error configuration could be something like: @@ -172,6 +174,7 @@ $ua->cookie_jar({}); $ua->agent(__PACKAGE__ . "/$VERSION"); $ua->default_header("Accept-Encoding" => "gzip, deflate"); + $ua->env_proxy() unless ($config->{noproxy}); $self->{ua} = $ua;
On Tue Dec 15 07:24:36 2009, http://andy.jenkinson.myopenid.com/ wrote: Show quoted text
> It would be very useful to add proxy support, currently not present. > > I have attached a patch to enable this feature in line with its > implementation in > WWW::Mechanize. That is, the MediaWiki::API constructor will call > 'env_proxy' on the underlying > LWP::UserAgent object unless instructed not to by a 'noproxy' config > parameter.
I think I would prefer it that you set a variable called proxy rather than having one "noproxy" as by default I would think most people don't want to proxy. However, you can already set the proxy by just creating a new instance of MediaWiki::API, and then doing MediaWiki::API->{ua}->env_proxy(). At least it should work like that. In some respects I prefer it this way, as then I don't have to built in every possible LWP function, and worry about what version of LWP has what.
I also meant to say thanks for the patch though ;-) I'm interested to hear your opinions on what I have suggested.
Subject: Re: [rt.cpan.org #52785] Request: proxy support
Date: Tue, 15 Dec 2009 13:55:57 +0000
To: bug-MediaWiki-API [...] rt.cpan.org
From: Andy Jenkinson <andy.jenkinson [...] gmail.com>
Hi Jools, The reason I did it that way is mainly for consistency with WWW:Mechanize. To put it into context: I have inherited some code that is using Perlwikipedia, which uses both WWW::Mechanize and MediaWiki::API. At the moment one object sets env_proxy by default, the other does not. One thing worth bearing in mind is that env_proxy only sets up a proxy if one is present in the environment (i.e. it inspects the http_proxy, https_proxy and no_proxy environment variables). So by calling env_proxy by default the API would not be assuming that users want a proxy (as you say, that would be inappropriate). What it would be assuming is that if the user has specifically defined proxy settings in their environment then they want those settings to be used. Of course this won't always be true (and you're right to be wary of changing default behaviour) but I would imagine that if users have these environment variables set then they are more likely to want them to be used than not. Of course it is completely up to you! As you say, compatibility with LWP is another factor to consider. Cheers, Andy On 15 Dec 2009, at 13:10, Jools Smyth via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=52785 > > > On Tue Dec 15 07:24:36 2009, http://andy.jenkinson.myopenid.com/ wrote:
>> It would be very useful to add proxy support, currently not present. >> >> I have attached a patch to enable this feature in line with its >> implementation in >> WWW::Mechanize. That is, the MediaWiki::API constructor will call >> 'env_proxy' on the underlying >> LWP::UserAgent object unless instructed not to by a 'noproxy' config >> parameter.
> > I think I would prefer it that you set a variable called proxy rather > than having one "noproxy" as by default I would think most people don't > want to proxy. However, you can already set the proxy by just creating a > new instance of MediaWiki::API, and then doing > MediaWiki::API->{ua}->env_proxy(). At least it should work like that. In > some respects I prefer it this way, as then I don't have to built in > every possible LWP function, and worry about what version of LWP has what. > >
Fixed/Added in 0.29 which should appear on CPAN shortly. After I uploaded I realised I had forgotten to credit you in the Changes text. I will add it now but it will be for the next version. Apologies.