Created
May 22, 2013 00:20
-
-
Save jberger/5624349 to your computer and use it in GitHub Desktop.
Example, counter to https://gist.github.com/tempire/5621542, which shows how when the ua is prevent from going out of scope, the warning is not encountered and the process succeeds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
app->attr( ua => sub { Mojo::UserAgent->new } ); | |
get '/' => sub { | |
my $self = shift; | |
$self->render_later; | |
$self->app->ua->get( 'http://tempi.re' => sub { | |
my ($ua, $tx) = @_; | |
warn $tx->error; # premature connection close | |
$self->render(text => $tx->res->body); | |
} ); | |
}; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment