Honor proxy env vars and reliably honor cookiejar.

master
Amitai Schlair 2013-07-27 08:12:01 -04:00
parent 07cb6368aa
commit 462d8f8015
4 changed files with 12 additions and 8 deletions

View File

@ -22,7 +22,7 @@ our @EXPORT = qw(hook debug error htmlpage template template_depends
htmllink readfile writefile pagetype srcfile pagename
displaytime strftime_utf8 will_render gettext ngettext urlto targetpage
add_underlay pagetitle titlepage linkpage newpagefile
inject add_link add_autofile
inject add_link add_autofile useragent
%config %links %pagestate %wikistate %renderedfiles
%pagesources %destsources %typedlinks);
our $VERSION = 3.00; # plugin interface version, next is ikiwiki version
@ -2274,6 +2274,13 @@ sub add_autofile ($$$) {
$autofiles{$file}{generator}=$generator;
}
sub useragent () {
return LWP::UserAgent->new(
cookie_jar => $config{cookiejar},
env_proxy => 1, # respect proxy env vars
);
}
sub sortspec_translate ($$) {
my $spec = shift;
my $reverse = shift;

View File

@ -522,11 +522,8 @@ sub aggregate (@) {
}
$feed->{feedurl}=pop @urls;
}
my $res=URI::Fetch->fetch($feed->{feedurl},
UserAgent => LWP::UserAgent->new(
cookie_jar => $config{cookiejar},
),
);
my $ua=useragent();
my $res=URI::Fetch->fetch($feed->{feedurl}, UserAgent=>$ua);
if (! $res) {
$feed->{message}=URI::Fetch->errstr;
$feed->{error}=1;

View File

@ -241,7 +241,7 @@ sub getobj ($$) {
$ua=LWPx::ParanoidAgent->new;
}
else {
$ua=LWP::UserAgent->new;
$ua=useragent();
}
# Store the secret in the session.

View File

@ -80,7 +80,7 @@ sub ping {
debug(gettext("LWP not found, not pinging"));
return;
}
$ua=LWP::UserAgent->new;
$ua=useragent();
}
$ua->timeout($config{pinger_timeout} || 15);