Skip Menu |
 

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

Report information
The Basics
Id: 58077
Status: rejected
Priority: 0/
Queue: MediaWiki-API

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

Bug Information
Severity: Wishlist
Broken in: 0.30
Fixed in: (no value)



Subject: Allow for using external LWP::UserAgent modules
Download (untitled) / with headers
text/plain 1.4k
Hi, I've extended LWP::UserAgent to work with our external HTTP authentication system (SiteMinder). You can either put the auth credentials in a file on the filesystem, or if you run the script that calls MediaWiki::API from a terminal, you'll get prompted to enter in your credentials via Term::ReadPassword. However, there's no way to pass in this user agent to MediaWiki::API as it's currently written, so I had to hack up API.pm to accept my custom LWP::UserAgent module. A patch with my differences would look something like this: --- API.pm.orig 2010-06-02 17:59:02.000000000 -0700 +++ API.pm 2010-06-02 17:50:03.000000000 -0700 @@ -167,15 +167,17 @@ Other useful parameters and objects in t sub new { - my ($class, $config) = @_; + my ($class, $config, $ua) = @_; my $self = { config => $config }; - my $ua = LWP::UserAgent->new(); - $ua->cookie_jar({}); - $ua->agent(__PACKAGE__ . "/$VERSION"); - $ua->default_header("Accept-Encoding" => "gzip, deflate"); - $ua->env_proxy() unless ($config->{no_proxy}); - + if ( ! defined $ua ) { + $ua = LWP::UserAgent->new(); + $ua->cookie_jar({}); + $ua->agent(__PACKAGE__ . "/$VERSION"); + $ua->default_header("Accept-Encoding" => "gzip, deflate"); + $ua->env_proxy() unless ($config->{no_proxy}); + } + # add the UserAgent object to this object so it can be used later Thanks, Brian perl -v This is perl, v5.8.8 built for i386-linux-thread-multi Red Hat Enterprise Server 5.4
Download (untitled) / with headers
text/plain 255b
Thanks for the report. Could you not just do my $mw = MediaWiki::API->new( { api_url => 'http://en.wikipedia.org/w/api.php' } ); $mw->{$ua} = LWP::UserAgent->new(); or whatever to set up the user agent manually as you need after creating the object ?
Subject: Re: [rt.cpan.org #58077] Allow for using external LWP::UserAgent modules
Date: Wed, 2 Jun 2010 22:27:41 -0700
To: bug-MediaWiki-API [...] rt.cpan.org
From: Brian Manning <elspicyjack [...] gmail.com>
Download (untitled) / with headers
text/plain 727b
On Wed, Jun 2, 2010 at 8:05 PM, Jools Smyth via RT <bug-MediaWiki-API@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=58077 > > > Thanks for the report. > > Could you not just do > > my $mw = MediaWiki::API->new( { api_url => > 'http://en.wikipedia.org/w/api.php' }  ); > $mw->{$ua} = LWP::UserAgent->new(); > > or whatever to set up the user agent manually as you need after creating > the object ?
It does work this way. I tried it during the course of troubleshooting problems with SiteMinder (external auth), but the issue turned out to be SiteMinder doing wierd things when using HTTP POST. You can close this if you want, I can get it to do what I want using your method above. Thanks, Brian
Download (untitled) / with headers
text/plain 380b
Show quoted text
> You can close this if you want, I can get it to do what I want using > your method above.
I'll leave this open for now. Even though you can recreate the ua object later it seems silly that in that case it is made twice. I might make a config option for it so it skips creation of the ua object (instead of adding a parameter). I just wanted to get the other bugfix out first.
Not going to implement after all - can be worked around as detailed in ticket.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.