Skip to content

Commit

Permalink
added SNI support to Mojo::IOLoop::Client and Mojo::UserAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 18, 2012
1 parent 3d2e444 commit 3efa303
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@
This file documents the revision history for Perl extension Mojolicious.

2.83 2012-04-18
- Added SNI support to Mojo::IOLoop::Client and Mojo::UserAgent.
- Improved documentation.
- Fixed bug that prevented conditions to work in embedded applications.
- Fixed bug that changed default values in embedded applications.
Expand Down
1 change: 1 addition & 0 deletions lib/Mojo/IOLoop/Client.pm
Expand Up @@ -90,6 +90,7 @@ sub _connect {
$self->_cleanup;
$self->emit_safe(error => $_[1]);
},
SSL_hostname => $args->{address},
SSL_cert_file => $args->{tls_cert},
SSL_key_file => $args->{tls_key},
SSL_ca_file => $args->{tls_ca}
Expand Down
9 changes: 4 additions & 5 deletions t/mojo/hypnotoad.t
Expand Up @@ -6,7 +6,11 @@ BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

# "I ate the blue ones... they taste like burning."
use Test::More;
plan skip_all => 'set TEST_HYPNOTOAD to enable this test (developer only!)'
unless $ENV{TEST_HYPNOTOAD};
plan tests => 50;

use Cwd 'cwd';
use File::Temp;
Expand All @@ -16,11 +20,6 @@ use Mojo::Command;
use Mojo::IOLoop;
use Mojo::UserAgent;

# "I ate the blue ones... they taste like burning."
plan skip_all => 'set TEST_HYPNOTOAD to enable this test (developer only!)'
unless $ENV{TEST_HYPNOTOAD};
plan tests => 50;

# Prepare script
my $cwd = cwd;
my $dir = File::Temp::tempdir(CLEANUP => 1);
Expand Down
1 change: 0 additions & 1 deletion t/mojo/morbo.t
Expand Up @@ -7,7 +7,6 @@ BEGIN {
}

use Test::More;

plan skip_all => 'set TEST_MORBO to enable this test (developer only!)'
unless $ENV{TEST_MORBO};
plan tests => 26;
Expand Down
1 change: 0 additions & 1 deletion t/mojo/reactor_ev.t
Expand Up @@ -4,7 +4,6 @@ use Mojo::Base -strict;
BEGIN { $ENV{MOJO_NO_BONJOUR} = $ENV{MOJO_NO_IPV6} = 1 }

use Test::More;

plan skip_all => 'set TEST_EV to enable this test (developer only!)'
unless $ENV{TEST_EV};
plan skip_all => 'EV 4.0 required for this test!' unless eval 'use EV 4.0; 1';
Expand Down
12 changes: 8 additions & 4 deletions t/mojo/user_agent.t
@@ -1,12 +1,12 @@
use Mojo::Base -strict;

# Disable Bonjour, IPv6 and libev
# Disable Bonjour, IPv6, TLS and libev
BEGIN {
$ENV{MOJO_NO_BONJOUR} = $ENV{MOJO_NO_IPV6} = 1;
$ENV{MOJO_NO_BONJOUR} = $ENV{MOJO_NO_IPV6} = $ENV{MOJO_NO_TLS} = 1;
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

use Test::More tests => 81;
use Test::More tests => 82;

# "The strong must protect the sweet."
use Mojo::IOLoop;
Expand Down Expand Up @@ -131,8 +131,12 @@ app->log->level('fatal');
app->log->on(message => $message);
like $err, qr/error event works/, 'right error';

# GET / (HTTPS request without TLS support)
my $tx = $ua->get($ua->app_url->scheme('https'));
like $tx->error, qr/IO::Socket::SSL/, 'right error';

# GET / (blocking)
my $tx = $ua->get('/');
$tx = $ua->get('/');
ok $tx->success, 'successful';
ok !$tx->kept_alive, 'kept connection not alive';
is $tx->res->code, 200, 'right status';
Expand Down
13 changes: 7 additions & 6 deletions t/mojo/user_agent_online.t
@@ -1,16 +1,17 @@
use Mojo::Base -strict;

# Disable libev and TLS
# Disable libev and proxy detection
BEGIN {
$ENV{MOJO_NO_TLS} = 1;
$ENV{MOJO_PROXY} = 0;
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

use Test::More;

use Mojo::IOLoop::Server;
plan skip_all => 'set TEST_ONLINE to enable this test (developer only!)'
unless $ENV{TEST_ONLINE};
plan skip_all => 'IO::Socket::SSL 1.37 required for this test!'
unless Mojo::IOLoop::Server::TLS;
plan tests => 106;

# "So then I said to the cop, "No, you're driving under the influence...
Expand Down Expand Up @@ -158,9 +159,9 @@ is $tx->req->method, 'GET', 'right method';
is $tx->req->url, 'http://cpan.org', 'right url';
is $tx->res->code, 301, 'right status';

# HTTPS request without TLS support
$tx = $ua->get('https://www.google.com');
ok !!$tx->error, 'request failed';
# HTTPS request that requires SNI
$tx = $ua->get('https://sni.velox.ch/');
like $tx->res->body, qr/Great!/, 'right response';

# Simple request with body
$tx = $ua->get('http://mojolicio.us' => 'Hi there!');
Expand Down
1 change: 0 additions & 1 deletion t/pod.t
@@ -1,7 +1,6 @@
use Mojo::Base -strict;

use Test::More;

plan skip_all => 'Test::Pod 1.14 required for this test!'
unless eval 'use Test::Pod 1.14; 1';
plan skip_all => 'set TEST_POD to enable this test (developer only!)'
Expand Down
1 change: 0 additions & 1 deletion t/pod_coverage.t
@@ -1,7 +1,6 @@
use Mojo::Base -strict;

use Test::More;

plan skip_all => 'Test::Pod::Coverage 1.04 required for this test!'
unless eval 'use Test::Pod::Coverage 1.04; 1';
plan skip_all => 'set TEST_POD to enable this test (developer only!)'
Expand Down

0 comments on commit 3efa303

Please sign in to comment.