Skip to content

Commit

Permalink
better CONNECT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 7, 2013
1 parent ba0f0dd commit c559f83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions t/mojo/websocket_proxy.t
Expand Up @@ -44,7 +44,7 @@ $daemon->listen(["http://127.0.0.1:$port"])->start;

# Connect proxy server for testing
my $proxy = Mojo::IOLoop->generate_port;
my (%buffer, $connected, $read, $sent, $fail);
my (%buffer, $connected, $read, $sent);
my $nf
= "HTTP/1.1 404 NOT FOUND\x0d\x0a"
. "Content-Length: 0\x0d\x0a"
Expand All @@ -69,7 +69,7 @@ Mojo::IOLoop->server(
$buffer{$client}{client} = '';
if ($buffer =~ /CONNECT (\S+):(\d+)?/) {
$connected = "$1:$2";
$fail = 1 if $2 == $port + 1;
my $fail = $2 == $port + 1;

# Connection to server
$buffer{$client}{connection} = Mojo::IOLoop->client(
Expand Down
10 changes: 8 additions & 2 deletions t/mojo/websocket_proxy_tls.t
Expand Up @@ -63,7 +63,7 @@ $daemon->listen([$listen])->start;

# Connect proxy server for testing
my $proxy = Mojo::IOLoop->generate_port;
my (%buffer, $connected, $read, $sent, $fail);
my (%buffer, $connected, $read, $sent);
my $nf
= "HTTP/1.1 404 NOT FOUND\x0d\x0a"
. "Content-Length: 0\x0d\x0a"
Expand All @@ -88,7 +88,7 @@ Mojo::IOLoop->server(
$buffer{$client}{client} = '';
if ($buffer =~ /CONNECT (\S+):(\d+)?/) {
$connected = "$1:$2";
$fail = 1 if $2 == $port + 1;
my $fail = $2 == $port + 1;

# Connection to server
$buffer{$client}{connection} = Mojo::IOLoop->client(
Expand Down Expand Up @@ -280,4 +280,10 @@ Mojo::IOLoop->start;
ok !$success, 'no success';
is $err, 'Proxy connection failed', 'right message';

# Blocking proxy request again
$ua->https_proxy("http://localhost:$proxy");
$tx = $ua->get("https://localhost:$port/proxy");
is $tx->res->code, 200, 'right status';
is $tx->res->body, "https://localhost:$port/proxy", 'right content';

done_testing();

0 comments on commit c559f83

Please sign in to comment.