in reply to Re^4: LWP::Parallel in other way
in thread LWP::Parallel in other way

You changed my code, so it works now? If not, just try. I have no idea, why it is not working at me, really. Please help.
All right. wait is not responsible for actualy making the request. How do I know?
Usually by reading the documentation, or by Devel::Trace (very verbose), but since this is LWP, LWP::Debug. Here's a little snip
C:\>perl -MLWP::Debug=+ foobar.pl LWP::UserAgent::new: () LWP::Parallel::UserAgent::in_order: (0) ***********snip********** LWP::Parallel::UserAgent::register: (http://2ge.mine.nu/headers.php, [ +undef], [undef], [undef]) LWP::Parallel::UserAgent::wait: Current Server: 0 [ ] Pending Server: 1 [ 2ge.mine.nu:80, 10 ] LWP::Parallel::UserAgent::_make_connections_unordered: () LWP::Parallel::UserAgent::_check_bandwith: (LWP::Parallel::UserAgent:: +Entry=HASH(0x1cbaf28) [http://2ge.mine.nu/headers.php] ) ***********snip********** LWP::Parallel::UserAgent::on_connect: (http://2ge.mine.nu/headers.php) LWP::Parallel::UserAgent::_connect: (LWP::Parallel::UserAgent::Entry=H +ASH(0x1cbb174) [http://2ge.mine.nu/headers.php] ) LWP::Parallel::UserAgent::init_request: -> (HTTP::Request=HASH(0x1cabe +6c)) [GET http://2ge.mine.nu/headers.php] LWP::Parallel::UserAgent::init_request: GET http://2ge.mine.nu/headers +.php LWP::UserAgent::_need_proxy: Not proxied LWP::Parallel::UserAgent::init_request: <- (undef, [undef], LWP::Paral +lel::Protocol::http=HASH(0x1d39fa4), 10, 1) LWP::Parallel::Protocol::http::_connect: Socket is IO::Socket::INET=GL +OB(0x1d3a058) LWP::Parallel::UserAgent::_check_bandwith: (LWP::Parallel::UserAgent:: +Entry=HASH(0x1cbb288) [http://2ge.mine.nu/headers.php] ) ***********snip********** LWP::Parallel::UserAgent::_perform_write: Writing to Sockets LWP::Parallel::Protocol::http::write_request: write_request (HTTP::Req +uest=HASH(0x1cac16c), IO::Socket::INET=GLOB(0x1d3e62c), /headers.php, + [undef], 1 0, [undef]) LWP::Parallel::Protocol::http::write_request: GET /headers.php HTTP/1. +0 Host: 2ge.mine.nu User-Agent: My agent 10 ***********snip**********
Now since most of these aren't documented, the time comes to source dive. I start by examining LWP::Parallel::Protocol::http::write_request (since it is responsible for making the request as evident by the trace), and I see
sub write_request { my ($self, $request, $socket, $fullpath, $arg, $timeout, $proxy) = @ +_; ***********snip********** my $h = $request->headers->clone; ***********snip**********
but its not where the headers are set (agent isn't mentioned).

So now I look earlier in the trace, and this time I notice LWP::Parallel::UserAgent::init_request, so I examine it

***********snip********** my ($agent, $from, $timeout, $cookie_jar, $use_eval, $parse_head, $max_size, $nonblock) = @{$self}{qw(agent from timeout cookie_jar use_eval parse_head max_size nonblock)}; # Set User-Agent and From headers if they are defined $request->init_header('User-Agent' => $agent) if $agent; ***********snip**********
and would you look at that I've found where the headers (in particular User-Agent) are initialized. See how that works?

Do you now know what you have to do?

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^6: LWP::Parallel in other way
by 2ge (Scribe) on Nov 03, 2004 at 17:51 UTC
    hello PodMaster !!!

    thanks for reply, I read 5 times your post, but I don't know what I should change in my script. I'm scripting in perl around 6 months, so I am not so good in debugging. Also I thought about that, it is not possible what I want in LWP::Parallel, maybe better is use more processes, but I 'm not sure. I thought LWP:P will be easier to use (I used it without no problems with the same UA). So, if you please could write me, what I should change in my code. Thanks.

    --
    Brano
      I read 5 times your post, but I don't know what I should change in my script
      Add something like $request->init_header('User-Agent' => $agent) in the appropriate spot (like where you create request objects).

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.