No, that would be a blocking request. The non-blocking format creates and sends the request, and stores the passed coderef to be called once the response is received. Additionally, making a shallow copy of the reference doesn't achieve anything, I meant (if it is a reference) you would need to copy the individual data within that you wish to use, outside of the coderef. -Dan
On Tue, Feb 28, 2017 at 11:19 PM, Jeremy Begg <[email protected]> wrote: > Given the better example, and Dan's suggestion, can you please clarify how > the callback routine is processed? > > I had thought it was not invoked until the HTTP transaction has completed, > but now I'm thinking that it's invoked as soon as the HTTP request is sent > and then the code stalls in *$tx->result *until the request completes. > Is that correct? If so then I guess Dan's suggestion would be coded as: > > sub send_data { > my $data = shift; > my $ua = Mojo::UserAgent->new; > my $request = $ua->post($upload_url => $data) => sub { > my ($ua, $tx) = @_; > my $localdata = $data; > my $res = $tx->result; # stall here > until HTTP response is received > post_process($localdata); > }); > return $request; > } > > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
