Do this: perldoc -mLWP::UserAgent
It'll give you the source code forLWP::UserAgent.
Then, in a sub or another package or a variety of ways..
NOTE:!!!!! Not-tested code, this is just a "for example" thing!
I'll probably goof this up, I'm editing "live" so beware...
sub get_ua {
{
package My::Ua;
useLWP::UserAgent;
use base 'LWP::UserAgent';
use strict;
# Use our bugged version to snoop in on things.
sub get {
my($self,@args) = @_;
print "CP1: $self called with " . join(',',@args), "\n";
my $rv = $self->SUPER::get(@args);
print "CP2: returning from get\n";
return($rv);
}
}
return(My::Ua->new(@_)); # Create our own version ofLWP::UserAgent.
}
When you construct yourLWP::UserAgent object, call get_ua() instead, in
the customized get() method above, you can insert print statements and
so on which will tell you the precise URL it's attempting to fetch. (you
can make a note of the URL's and observe if it's always the same URL,
this would be a key piece of information)
Confirm things are as they should, then follow along the path ofLWP
until you get to request() (and at that point.. it's probably just
as easy to copy the whole thing over and pollute with print statements)
placing "CPnnn" statements in along the way.
At the end of it all, you'll get to a point where there isn't a "CPnnn"
printed where you think there ought to be one. At that point, you'll
have found exactly where it's hanging, and, if you're lucky.. it'll
be something obvious.
If not, at least you'll have a good idea what's
wrong.
Do NOT modify the source ofLWP::UserAgent (or any other module for that
matter) directly, always copy, or if it's more convenient, do a
custom override as above. Otherwise you'll end up with corrupt modules.
See Also:LWP:
ebug
Though I've never used it, every problem I've ever had was as a result of me
passing the wrong stuff into get/post, I've never had to go further than what
I've described above. (and I usually overrideLWP::UserAgent in the beginning
anyway, just in case I might want to change it's behavior later on in
program development, ex: password fetching)
The above is just a debugging method I've found useful for "tough cases".
Jamie
--http://
www.geniegate.com Custom web programming
Perl * Java * UNIX User Management Solutions