]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Bug#737121: ikiwiki: [PATCH] Implement configuration option to set the user agent...
authorTuomas Jormola <tj@solitudo.net>
Thu, 30 Jan 2014 12:41:55 +0000 (14:41 +0200)
committerJoey Hess <joey@kitenet.net>
Sat, 1 Feb 2014 20:53:33 +0000 (16:53 -0400)
Package: ikiwiki
Version: 3.20140125
Severity: wishlist

By default, LWP::UserAgent used by IkiWiki to perform outbound HTTP
requests sends the string "libwww-perl/<version number>" 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.

IkiWiki.pm
IkiWiki/Plugin/openid.pm
IkiWiki/Plugin/pinger.pm

index b7080bb0b3ff14f1af78dd1633a1f05ed722d6d6..eb480969bd6fc0b72565a09fbb607a97fb94d52d 100644 (file)
@@ -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},
        );
 }
 
index d369e30c995277f8a5e7f5bccdd5cd17dbcea0aa..3b96e4b8e411c5f29afc25b58e15cdfd9f70121d 100644 (file)
@@ -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();
index fb0f3ba0aa9cf9676f95eaded1f4569504015c99..b2d54af8ac269cd63e95913073919cfd2b496052 100644 (file)
@@ -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};