LWP::Parallel::UserAgent default headers patch

LWP::Parallel::UserAgent default headers patch

am 04.07.2007 05:34:10 von pknewsgroups

--------------090401010002050304060702
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


Hello!

I was playing around LWP::Parallel::UserAgent and noticed that if I set
default_headers() which is LWP::UserAgent's method, the parallel UA
never used them for requests.
This little patch ensures that the default headers are added to each
parallel ua's request.


P.Krumins

--------------090401010002050304060702
Content-Type: text/plain;
name="lwp.parallel.ua.patch.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="lwp.parallel.ua.patch.diff"

--- UserAgent.original.pm 2004-02-10 17:19:20.000000000 +0200
+++ UserAgent.pm 2007-07-04 06:03:24.890625000 +0300
@@ -1493,6 +1493,13 @@
$request->init_header('Range' => "bytes=0-$max_size") if $max_size;
$cookie_jar->add_cookie_header($request) if $cookie_jar;

+ my $def_headers = $self->default_headers;
+ if ($def_headers) {
+ for my $h ($def_headers->header_field_names) {
+ $request->init_header($h => [$def_headers->header($h)]);
+ }
+ }
+
# Transfer some attributes to the protocol object
$protocol->parse_head($parse_head);
$protocol->max_size($max_size);

--------------090401010002050304060702--