Subject: | The custom User-Agent is not used since version 5.833 of libwww-perl |
Since version 5.833 of libwww-perl, setting the default headers of a
LWP::UserAgent with method default_headers() clears the User-Agent header
set at instance creation:
$ perl -MLWP::UserAgent -wle 'my $ua = LWP::UserAgent->new(agent =>
"My agent"); print "Before setting default headers:\n", $ua->default_headers-
Show quoted text
>as_string, "EOF\n"; $ua->default_headers( HTTP::Headers->new ); print
"After setting default headers:\n", $ua->default_headers->as_string, "EOF"'
Before setting default headers:
User-Agent: My agent
EOF
After setting default headers:
EOF
The proposed attached patch sets the custom user agent string after setting
the default header.
Subject: | WebService-UrbanAirship-0.04-set_ua_agent.patch |
Set User-Agent after the default headers, probably newer LWP::UserAgent
versions clear the User-Agent header when setting the default headers.
--- WebService-UrbanAirship-0.04/lib/WebService/UrbanAirship/APNS.pm.orig 2009-10-02 19:18:29.000000000 +0300
+++ WebService-UrbanAirship-0.04/lib/WebService/UrbanAirship/APNS.pm 2011-09-04 19:06:28.924746514 +0300
@@ -72,7 +72,7 @@
my %args = @_;
my $ua = $self->{_ua} ||
- LWP::UserAgent->new(agent => $self->_agent(),
+ LWP::UserAgent->new(
protocols_allowed => [ qw(https) ],
timeout => $self->_timeout(),
);
@@ -88,6 +88,8 @@
$ua->default_headers($headers);
+ $ua->agent($self->_agent);
+
$self->{_ua} = $ua;
return $ua;