Folks,
I have the following code. When I use the non-blocking version, I get the
following error with a dump of the transaction object...Any assistance
would be greatly appreciated:
Use of uninitialized value $url in pattern match (m//) at
/tempssd/bossert/perl-5.20/lib/site_perl/5.20.1/Mojo/UserAgent/Transactor.pm
line 107.
Use of uninitialized value $url in concatenation (.) or string at
/tempssd/bossert/perl-5.20/lib/site_perl/5.20.1/Mojo/UserAgent/Transactor.pm
line 107.
$VAR1 = bless( {
'req' => bless( {
'content' => bless( {
'headers' =>
bless( {
'headers' => {
'user-agent' => [
'Mojolicious (Perl)'
],
'accept-encoding' => [
'gzip'
]
}
}, 'Mojo::Headers' ),
'events' => {
'read' => [
sub { "DUMMY" }
]
},
'read' =>
$VAR1->{'req'}{'content'}{'events'}{'read'}[0]
},
'Mojo::Content::Single' ),
'url' => bless( {
'query' => bless( {
'string' => undef
},
'Mojo::Parameters' ),
'scheme' => 'https',
'fragment' => undef,
'host' => '',
'path' => bless( {
'charset' => 'UTF-8',
'trailing_slash' => '',
'parts' => [],
'leading_slash' => ''
},
'Mojo::Path' )
}, 'Mojo::URL' ),
'method' => 'POST'
}, 'Mojo::Message::Request' ),
'res' => bless( {
'state' => 'finished',
'finished' => 2,
'error' => {
'message' => 'Connection
refused'
},
'events' => {},
'content' => bless( {
'headers' =>
bless( {
'headers' => {}
}, 'Mojo::Headers' ),
'events' => {
'read' => [
$VAR1->{'req'}{'content'}{'events'}{'read'}[0]
]
},
'read' =>
$VAR1->{'req'}{'content'}{'events'}{'read'}[0]
},
'Mojo::Content::Single' )
}, 'Mojo::Message::Response' ),
'events' => {},
'state' => 'finished'
}, 'Mojo::Transaction::HTTP' );
This code works fine:
get 'dbstart' => sub {
my $self = shift;
my $qparams=$self->req->query_params->to_hash;
if (!$self->session('host')) {
$self->session(expires => 1);
delete $users{$self->tx->remote_address};
$self->rendered(401);
}
else {
my $tx = $ua->post('https://
'.$self->session('host').'/urika-admin/internal/api/db/'.$qparams->{'id'}.'/start');
if($tx->success) {
$self->rendered(200);
}
else {
if (!defined $tx->res->code) {
say Dumper($tx);
$self->rendered(500);
}
elsif ($tx->res->code == 401 or $tx->res->code == 403) {
$self->session(expires => 1);
delete $users{$self->tx->remote_address};
$self->rendered($tx->res->code);
}
else {
$self->rendered($tx->res->code);
}
}
}
};
This code won't work and produces the error from above:
get 'dbstart' => sub {
my $self = shift;
my $qparams=$self->req->query_params->to_hash;
if (!$self->session('host')) {
$self->session(expires => 1);
delete $users{$self->tx->remote_address};
$self->rendered(401);
}
else {
$ua->post('https://'.$self->session('host').'/urika-admin/internal/api/db/'.$qparams->{'id'}.'/start'
= sub {
my ($ua1,$tx) = @_;
if($tx->success) {
$self->rendered(200);
}
else {
if (!defined $tx->res->code) {
say Dumper($tx);
$self->rendered(500);
}
elsif ($tx->res->code == 401 or $tx->res->code == 403) {
$self->session(expires => 1);
delete $users{$self->tx->remote_address};
$self->rendered($tx->res->code);
}
else {
$self->rendered($tx->res->code);
}
}
});
};
--
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.