Hi,
I've realised that in my original problem statement (above) I omitted a
critical line of code.
I've added that line below, i.e.
*my $res = $tx->result;*
On Wednesday, March 1, 2017 at 10:46:22 AM UTC+10:30, Jeremy Begg wrote:
>
> Hi,
>
> I'm working on an application that uses Mojo::UserAgent to send data to
> another system, preferably non-blocking.
> The code looks something like this (greatly simplified):
>
> sub send_data {
> my $data = shift;
> my $ua = Mojo::UserAgent->new;
> my $request = $ua->post($upload_url => $data) => sub {
> my ($ua, $tx) = @_;
> my $res = $tx->result;
> post_process($data);
> });
> return $request;
> }
>
>
> I am concerned that by the time the callback occurs, $data will contain
> something other than what was sent via the POST that sent it, and so the
> post-processing routine (not shown here) will misbehave.
> The response body from the remote system does not contain any context
> information about the request sent to it; all it returns is a success/fail
> status and (if successful) the number of items uploaded.
>
> How can I save the value of $data for use by the callback? Is there a
> mechanism to attach local state information to the $ua->post() which is
> handed to the callback when it is invoked?
> (I can't see any reference to such in the documentation for
> Mojo::UserAgent.)
>
> Thanks,
> Jeremy Begg
>
--
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.