[Mojolicious] Cancel in-flight HTTP request?

2020-10-23 Thread Felipe Gasper
Hi all, Does Mojo::UA offer a control to cancel an in-flight HTTP request? I don’t see one in the docs but wonder if I’m just missing it. (The promise, of course, can be pre-resolved/rejected, but that doesn’t appear to affect the underlying HTTP request.) Thank you! c

Re: [Mojolicious] Cancel in-flight HTTP request?

2020-10-23 Thread Dmitry L.
https://metacpan.org/pod/Mojo::Transaction#completed On Fri, 23 Oct 2020 at 17:07, Felipe Gasper wrote: > > Hi all, > > Does Mojo::UA offer a control to cancel an in-flight HTTP request? I > don’t see one in the docs but wonder if I’m just missing it. > > (The promise, of course,

Re: [Mojolicious] Cancel in-flight HTTP request?

2020-10-23 Thread Felipe Gasper
Thank you! When I try: use Mojo::UserAgent; my $ua = Mojo::UserAgent->new; my $p = $ua->get_p('http://www.google.com'); Mojo::Promise->timer(0.01)->then( sub { print "canceling\n"; $p->completed() } ); Mojo::Promise->timer(2)->wait(); … then strace that script, the request continu

Re: [Mojolicious] Cancel in-flight HTTP request?

2020-10-23 Thread Sebastian Riedel
You can set a response error on the transaction to cancel it safely. That's what the Mojolicious tests use. -- sebastian -- 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 e

Re: [Mojolicious] Cancel in-flight HTTP request?

2020-10-23 Thread Dmitry L.
> my $p = $ua->get_p('http://www.google.com'); > https://metacpan.org/pod/Mojo::UserAgent#get_p returns a Mojo::Promise object > Mojo::Promise->timer(0.01)->then( sub { print "canceling\n"; $p->completed() > } ); > https://metacpan.org/pod/Mojo::Promise doesn't have `completed` method your are ca

Re: [Mojolicious] Cancel in-flight HTTP request?

2020-10-23 Thread Felipe Gasper
> On Oct 23, 2020, at 10:42 AM, Dmitry L. wrote: > >> my $p = $ua->get_p('http://www.google.com'); >> > https://metacpan.org/pod/Mojo::UserAgent#get_p returns a Mojo::Promise object > >> Mojo::Promise->timer(0.01)->then( sub { print "canceling\n"; $p->completed() >> } ); >> > https://metacp

Re: [Mojolicious] Cancel in-flight HTTP request?

2020-10-26 Thread Felipe Gasper
> On Oct 23, 2020, at 10:42 AM, Dmitry L. wrote: > >> my $p = $ua->get_p('http://www.google.com'); >> > https://metacpan.org/pod/Mojo::UserAgent#get_p returns a Mojo::Promise object > >> Mojo::Promise->timer(0.01)->then( sub { print "canceling\n"; $p->completed() >> } ); >> > https://metacp