Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed bug in Mojo::UserAgent where not all 2xx responses would be acc…
…epted for CONNECT requests
  • Loading branch information
kraih committed Jul 7, 2013
1 parent 6fed490 commit e852bb0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,6 +1,8 @@

4.18 2013-07-07
- Added --mode option to Morbo.
- Fixed bug in Mojo::UserAgent where not all 2xx responses would be accepted
for CONNECT requests.

4.17 2013-07-04
- Updated jQuery to version 2.0.3.
Expand Down
4 changes: 2 additions & 2 deletions examples/connect-proxy.pl
Expand Up @@ -4,7 +4,7 @@

use Mojo::IOLoop;

# Minimal connect proxy server to test TLS tunneling
# Minimal CONNECT proxy server to test TLS tunneling
my %buffer;
Mojo::IOLoop->server(
{port => 3000} => sub {
Expand Down Expand Up @@ -79,7 +79,7 @@
) or die "Couldn't create listen socket!\n";

print <<'EOF';
Starting connect proxy on port 3000.
Starting CONNECT proxy on port 3000.
For testing use something like "HTTPS_PROXY=http://127.0.0.1:3000".
EOF

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/UserAgent.pm
Expand Up @@ -197,7 +197,7 @@ sub _connect_proxy {
my ($self, $tx) = @_;

# CONNECT failed (connection needs to be kept alive)
unless ($tx->keep_alive && ($tx->res->code // '') eq '200') {
unless ($tx->keep_alive && $tx->res->is_status_class(200)) {
$old->req->error('Proxy connection failed');
return $self->_finish($old, $cb);
}
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/websocket_proxy.t
Expand Up @@ -42,7 +42,7 @@ my $daemon = Mojo::Server::Daemon->new(app => app, silent => 1);
my $port = Mojo::IOLoop->new->generate_port;
$daemon->listen(["http://127.0.0.1:$port"])->start;

# Connect proxy server for testing
# CONNECT proxy server for testing
my $proxy = Mojo::IOLoop->generate_port;
my (%buffer, $connected, $read, $sent);
my $nf
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/websocket_proxy_tls.t
Expand Up @@ -65,10 +65,10 @@ $daemon->listen([$listen])->start;
my $proxy = Mojo::IOLoop->generate_port;
my (%buffer, $connected, $read, $sent);
my $nf
= "HTTP/1.1 404 NOT FOUND\x0d\x0a"
= "HTTP/1.1 501 FOO\x0d\x0a"
. "Content-Length: 0\x0d\x0a"
. "Connection: close\x0d\x0a\x0d\x0a";
my $ok = "HTTP/1.0 200 OK\x0d\x0aX-Something: unimportant\x0d\x0a\x0d\x0a";
my $ok = "HTTP/1.0 201 BAR\x0d\x0aX-Something: unimportant\x0d\x0a\x0d\x0a";
Mojo::IOLoop->server(
{address => '127.0.0.1', port => $proxy} => sub {
my ($loop, $stream, $client) = @_;
Expand Down

0 comments on commit e852bb0

Please sign in to comment.