From 462d8f8015db338c7a5c718f1b92006c2bee9cfe Mon Sep 17 00:00:00 2001 From: Amitai Schlair Date: Sat, 27 Jul 2013 08:12:01 -0400 Subject: [PATCH] Honor proxy env vars and reliably honor cookiejar. --- IkiWiki.pm | 9 ++++++++- IkiWiki/Plugin/aggregate.pm | 7 ++----- IkiWiki/Plugin/openid.pm | 2 +- IkiWiki/Plugin/pinger.pm | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index c497dd38f..3fc0c7d8a 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -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; diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index be6e8d476..ccbc6c9a9 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -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; diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index e3b9982f2..d369e30c9 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -241,7 +241,7 @@ sub getobj ($$) { $ua=LWPx::ParanoidAgent->new; } else { - $ua=LWP::UserAgent->new; + $ua=useragent(); } # Store the secret in the session. diff --git a/IkiWiki/Plugin/pinger.pm b/IkiWiki/Plugin/pinger.pm index 588f7a42a..fb0f3ba0a 100644 --- a/IkiWiki/Plugin/pinger.pm +++ b/IkiWiki/Plugin/pinger.pm @@ -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); -- 2.39.5