LWP::Parallel::UserAgent default headers patch
"Peteris Krumins [Newsgroups]" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Message-ID | <[email protected]> |
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
lwp.parallel.ua.patch.diff
(text/plain, 626 B)
--- 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);