Skip to content

Commit

Permalink
improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jberger committed Mar 12, 2016
1 parent a999f69 commit 4f00c4c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -218,7 +218,7 @@ sub _finish {
$c->{ioloop}->remove($c->{timeout}) if $c->{timeout};
return $self->_reuse($id, $close) unless my $old = $c->{tx};

# Premature connection close or 4xx/5xx
# Premature connection close
my $res = $old->closed->res->finish;
if ($close && !$res->code && !$res->error) {
$res->error({message => 'Premature connection close'});
Expand All @@ -237,11 +237,15 @@ sub _finish {
return $new->client_read($old->res->content->leftovers);
}

# Finish connection and handle redirects
# Finish connection
$self->_reuse($id, $close);

# Set error for 4xx/5xx
if ($res->is_status_class(400) || $res->is_status_class(500)) {
$res->error({message => $res->message, code => $res->code});
}

# Handle redirects or invoke callback
$c->{cb}($self, $old) unless $self->_redirect($c, $old);
}

Expand Down

0 comments on commit 4f00c4c

Please sign in to comment.