From: Tuomas Jormola Date: Thu, 30 Jan 2014 12:41:55 +0000 (+0200) Subject: Bug#737121: ikiwiki: [PATCH] Implement configuration option to set the user agent... X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/dc53ca18f2bbbfe93be2786680f3afe1bd24afea?hp=79e40f031811c38ed9eb6e3c17dfded63310b5eb Bug#737121: ikiwiki: [PATCH] Implement configuration option to set the user agent string for outbound HTTP requests Package: ikiwiki Version: 3.20140125 Severity: wishlist By default, LWP::UserAgent used by IkiWiki to perform outbound HTTP requests sends the string "libwww-perl/" as User-Agent header in HTTP requests. Some blogging platforms have blacklisted the user agent and won't serve any content for clients using this user agent string. With IkiWiki configuration option "useragent" it's now possible to define a custom string that is used for the value of the User-Agent header. --- diff --git a/IkiWiki.pm b/IkiWiki.pm index b7080bb0b..eb480969b 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -527,6 +527,14 @@ sub getsetup () { safe => 0, # hooks into perl module internals rebuild => 0, }, + useragent => { + type => "string", + default => undef, + example => "Wget/1.13.4 (linux-gnu)", + description => "set custom user agent string for outbound HTTP requests e.g. when fetching aggregated RSS feeds", + safe => 0, + rebuild => 0, + }, } sub defaultconfig () { @@ -2301,6 +2309,7 @@ sub useragent () { return LWP::UserAgent->new( cookie_jar => $config{cookiejar}, env_proxy => 1, # respect proxy env vars + agent => $config{useragent}, ); } diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index d369e30c9..3b96e4b8e 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -238,7 +238,7 @@ sub getobj ($$) { my $ua; eval q{use LWPx::ParanoidAgent}; if (! $@) { - $ua=LWPx::ParanoidAgent->new; + $ua=LWPx::ParanoidAgent->new(agent => $config{useragent}); } else { $ua=useragent(); diff --git a/IkiWiki/Plugin/pinger.pm b/IkiWiki/Plugin/pinger.pm index fb0f3ba0a..b2d54af8a 100644 --- a/IkiWiki/Plugin/pinger.pm +++ b/IkiWiki/Plugin/pinger.pm @@ -72,7 +72,7 @@ sub ping { my $ua; eval q{use LWPx::ParanoidAgent}; if (!$@) { - $ua=LWPx::ParanoidAgent->new; + $ua=LWPx::ParanoidAgent->new(agent => $config{useragent}); } else { eval q{use LWP};