package TestTest; use strict; use warnings; use base 'Mojo::Base'; use Mojo::Client; use Mojo::IOLoop; sub request { my ($self) = @_; my $client = Mojo::Client->singleton; $client->ioloop(Mojo::IOLoop->singleton); my $stop_server = ! Mojo::IOLoop->singleton->is_running; $client->async->get( 'http://google.com/', sub { my ($self, $tx) = @_; print "Got google!\n"; $client->async->get( 'http://localhost:8080', sub { my ($self, $tx) = @_; warn $tx->res->body; Mojo::IOLoop->singleton->stop if $stop_server; })->process, })->process; Mojo::IOLoop->singleton->start; print "here\n"; } 1;