Skip to content

Commit

Permalink
better transactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 8, 2012
1 parent 0761cee commit 881e248
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -211,11 +211,8 @@ sub _connect {
sub _connect_proxy {
my ($self, $old, $cb) = @_;

# Check if CONNECT request is necessary
return undef unless $old->req->method ne 'CONNECT';
return undef unless my $new = $self->transactor->proxy_connect($old);

# Start CONNECT request
return undef unless my $new = $self->transactor->proxy_connect($old);
return $self->_start(
$new => sub {
my ($self, $tx) = @_;
Expand Down
5 changes: 4 additions & 1 deletion lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -111,8 +111,11 @@ sub peer {
sub proxy_connect {
my ($self, $old) = @_;

# No proxy
# Already a CONNECT request
my $req = $old->req;
return undef if $req->method eq 'CONNECT';

# No proxy
return undef unless my $proxy = $req->proxy;

# WebSocket and/or HTTPS
Expand Down
1 change: 1 addition & 0 deletions t/mojo/transactor.t
Expand Up @@ -355,6 +355,7 @@ ok !$tx->req->headers->authorization, 'no "Authorization" header';
is $tx->req->headers->proxy_authorization, 'Basic c3JpOnNlY3IzdA==',
'right "Proxy-Authorization" header';
is $tx->req->headers->host, '127.0.0.1:3000', 'right "Host" header';
is $t->proxy_connect($tx), undef, 'already a CONNECT request';

# Simple 302 redirect
$tx = $t->tx(
Expand Down

0 comments on commit 881e248

Please sign in to comment.