Subject: | [Patch] Does not honor LWP::UserAgent defaults |
LWP::UesrAgent::POE is not quite a drop-in replacement for
LWP::UserAgent as documented as it does not use the same defaults.
The attached patch, with tests, corrects this discrepancy.
-Marc
Subject: | lwp-ua-poe.patch |
diff --git a/POE.pm b/POE.pm
index ecd091e..49ef7a6 100644
--- a/POE.pm
+++ b/POE.pm
@@ -25,6 +25,13 @@ sub new {
my $self = bless {
await_id => 0,
poco_alias => "lwp_useragent_poe_http_client_poco",
+
+ # LWP::UserAgent defaults
+ agent => "libwww-perl/$LWP::UserAgent::VERSION",
+ max_redirect => 7,
+ parse_head => 1,
+ requests_redirectable => [qw/GET HEAD/],
+ timeout => 180,
%options,
}, $class;
diff --git a/t/lwp_useragent_compat.t b/t/lwp_useragent_compat.t
new file mode 100644
index 0000000..690c75a
--- /dev/null
+++ b/t/lwp_useragent_compat.t
@@ -0,0 +1,29 @@
+use warnings;
+use strict;
+use Test::More;
+
+use LWP::UserAgent::POE;
+
+my @defaults = qw/
+ agent
+ from
+ conn_cache
+ cookie_jar
+ default_headers
+ max_size
+ max_redirect
+ parse_head
+ protocols_allowed
+ protocols_forbidden
+ requests_redirectable
+ timeout
+/;
+
+plan tests => scalar @defaults;
+
+my $ua = LWP::UserAgent->new;
+my $uap = LWP::UserAgent::POE->new;
+
+is_deeply $uap->$_, $ua->$_, $_ for @defaults;
+
+POE::Kernel->run;