Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 7, 2013
1 parent c559f83 commit 1beb4fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -196,7 +196,7 @@ sub _connect_proxy {
$new => sub {
my ($self, $tx) = @_;

# CONNECT failed
# CONNECT failed (connection needs to be kept alive)
unless ($tx->keep_alive && ($tx->res->code // '') eq '200') {
$old->req->error('Proxy connection failed');
return $self->_finish($old, $cb);
Expand Down Expand Up @@ -354,14 +354,14 @@ sub _remove {

# Close connection
my $tx = (delete($self->{connections}{$id}) || {})->{tx};
unless (!$close && $tx && $tx->keep_alive && !$tx->error) {
if ($close || !$tx || !$tx->keep_alive || $tx->error) {
$self->_cache($id);
return $self->_loop->remove($id);
}

# Keep connection alive
# Keep connection alive (CONNECT requests get upgraded)
$self->_cache(join(':', $self->transactor->endpoint($tx)), $id)
unless uc $tx->req->method eq 'CONNECT' && ($tx->res->code // '') eq '200';
unless uc $tx->req->method eq 'CONNECT';
}

sub _redirect {
Expand Down

0 comments on commit 1beb4fd

Please sign in to comment.