Skip to content

Commit

Permalink
better explanation for app_url behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 10, 2012
1 parent 5192c7d commit a6ef98c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

3.06 2012-07-09
3.06 2012-07-10
- Improved documentation.
- Improved tests.

3.05 2012-07-08
Expand Down
8 changes: 4 additions & 4 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -167,7 +167,6 @@ sub _cleanup {
return unless my $loop = $self->_loop;

# Stop server
delete $self->{port};
delete $self->{server};

# Clean up active connections
Expand Down Expand Up @@ -409,9 +408,8 @@ sub _redirect {
sub _server {
my ($self, $scheme) = @_;

# Restart with different scheme
delete $self->{port} if $scheme;
return $self->{server} if $self->{port};
# Reuse server
return $self->{server} if $self->{server} && !$scheme;

# Start test server
my $loop = $self->_loop;
Expand Down Expand Up @@ -818,6 +816,8 @@ C<MOJO_APP> environment variable or a L<Mojo::HelloWorld> object.
my $url = $ua->app_url('https');
Get absolute L<Mojo::URL> object for C<app> and switch protocol if necessary.
Note that the port may change when switching from blocking to non-blocking
requests.
# Port currently used for processing relative URLs
say $ua->app_url->port;
Expand Down
9 changes: 3 additions & 6 deletions t/mojo/user_agent.t
Expand Up @@ -292,18 +292,15 @@ is $stream, 1, 'no leaking subscribers';
# Nested keep alive
my @kept_alive;
$ua->get(
'/',
sub {
'/' => sub {
my ($self, $tx) = @_;
push @kept_alive, $tx->kept_alive;
$self->get(
'/',
sub {
'/' => sub {
my ($self, $tx) = @_;
push @kept_alive, $tx->kept_alive;
$self->get(
'/',
sub {
'/' => sub {
my ($self, $tx) = @_;
push @kept_alive, $tx->kept_alive;
Mojo::IOLoop->stop;
Expand Down

0 comments on commit a6ef98c

Please sign in to comment.