# set up callback { my $gen = $req->content(); die unless ref($gen) eq "CODE"; my $i = 0; $req->content( sub { my $chunk = &$gen(); # get chunk of data warn $i++; return $chunk; # send it to $url } );