ropey has asked for the wisdom of the Perl Monks concerning the following question:

Hell fellow monks

Got a strange problem, can't seem to work out how to manage, am using LWP::Parallel::UserAgent to query a webservice in pseudo parallel, I also use the callback feature so that when a request is completed, the specifed callback sub is called. This is all standard UserAgent stuff, however the problem is that the request coming back is coming back in Chunked parts.

So what I would like to see is this Send off a request - when FULL request comes back (no chunks) then the callback sub is called and the complete request processed. However the problem is that its coming back in Chunks, and for every chunk of the data the callback sub is called. According to the documentation you can specify a chunk size, have tried to specify a high chunk size so that it all comes back in one chunk... but to no avail - has any other monk come across this and has a fix... or is my explaination of the problem too ropey....

  • Comment on LWP::Parallel::userAgent Disable Chunks

Replies are listed 'Best First'.
Re: LWP::Parallel::userAgent Disable Chunks
by merlyn (Sage) on Jul 19, 2005 at 11:42 UTC
    Don't use a callback then. If you don't use a callback, the response accumulates into the response record. Instead, subclass LWP::Parallel::UserAgent replacing the "on_return" null call with your own:
    $ua->on_return ( $request, $response, $entry ) This method should be overridden in an (otherwise empty) su +bclass in order to present customized messages for each request re +turned. If a callback function was registered with this request, th +is call- back function is called before $pua->on_return. Please note that while $pua->on_return is a method (which s +hould be overridden in a subclass), a callback function is NOT a met +hod, and does not have $self as its first parameter. (See more on ca +llbacks below) The purpose of $pua->on_return is mainly to provide message +s when a request returns. However, you can also re-register follow-u +p requests in case you need them. If you need specialized follow-up requests depending on the + request that just returend, use a callback function instead (which +can be different for each request registered). Otherwise you might + end up writing a HUGE if..elsif..else.. branch in this global meth +od.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.