Skip to content

Commit

Permalink
reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 15, 2009
1 parent f887094 commit 06ee1a1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -77,6 +77,7 @@ This file documents the revision history for Perl extension Mojo.
- Fixed max_age in Mojo::Cookie.
- Fixed cloning of urls with base in Mojo::URL.
- Fixed parsing of multiple headers and cookies with same name.
- Fixed pipeline support in Mojo::Client. (acajou)

0.991246 2009-08-01 00:00:00
- Fixed typo.
Expand Down
17 changes: 6 additions & 11 deletions lib/Mojo/Client.pm
Expand Up @@ -313,10 +313,9 @@ sub spin_app {
return 1;
}

# Make sure $server has a transaction ready to handle data
unless ($server->_current_active) {
$server->server_accept($daemon->build_tx_cb->($daemon));
}
# Make sure the server has a transaction ready to handle incoming data
$server->server_accept($daemon->build_tx_cb->($daemon))
unless $server->server_tx;

# Exchange
if ($client->client_is_writing || $server->server_is_writing) {
Expand Down Expand Up @@ -369,19 +368,15 @@ sub spin_app {

# Handle
$self->_handle_app($daemon, $server);

}

}

# Done
return 1 if $client->is_finished;

# Check for server closing the connection
if ($server->is_done && !$server->keep_alive) {
$client->error("Server closed connection");
return 1;
}
# Check if server closed the connection
$client->error('Server closed connection.') and return 1
if $server->is_done && !$server->keep_alive;

# More to do
return;
Expand Down
10 changes: 3 additions & 7 deletions t/mojo/app.t
Expand Up @@ -62,32 +62,28 @@ is($tx->res->code, 417);
is($tx->res->headers->connection, 'Close');

# Regular pipeline
my $tx1 = Mojo::Transaction::Single->new_get('/4/');
my $tx2 = Mojo::Transaction::Single->new_get('/5/');
my $tx1 = Mojo::Transaction::Single->new_get('/4/');
my $tx2 = Mojo::Transaction::Single->new_get('/5/');
my $pipe = Mojo::Transaction::Pipeline->new($tx1, $tx2);
$client->process_app('ContinueHandlerTest', $pipe);

ok($pipe->is_done);
ok($pipe->keep_alive);
ok($tx1->is_done);
ok($tx2->is_done);
is(scalar @{$pipe->finished}, 2);

# Interrupted pipeline

$tx1 = Mojo::Transaction::Single->new_get('/6/');
$tx2 = Mojo::Transaction::Single->new_post('/7/');
$tx2->req->headers->expect('100-continue');
$tx2->req->body('bar baz foo' x 128);
my $tx3 = Mojo::Transaction::Single->new_get('/8/');
$pipe = Mojo::Transaction::Pipeline->new($tx1, $tx2, $tx3);

$client->process_app('ContinueHandlerTest', $pipe);

ok($pipe->is_finished);
ok($pipe->has_error);
ok($tx1->is_done);
ok($tx2->is_done);
ok(!$tx3->is_done);
is(scalar @{$pipe->finished}, 2);
is(scalar @{$pipe->active}, 1);
is(scalar @{$pipe->active}, 1);
7 changes: 3 additions & 4 deletions t/mojo/pipeline.t
Expand Up @@ -215,7 +215,6 @@ $pipe->safe_post(0);
ok($pipe->client_is_writing);

# Premature connection close

$tx1 = Mojo::Transaction::Single->new_get("http://127.0.0.1:3000/18/");
$tx2 = Mojo::Transaction::Single->new_get("http://127.0.0.1:3000/19/");
$tx3 = Mojo::Transaction::Single->new_get("http://127.0.0.1:3000/20/");
Expand All @@ -242,8 +241,8 @@ ok(!$tx3->is_done);
is($tx1->res->code, 204);
is($tx2->res->code, 200);
ok(!$pipe->keep_alive);
is($pipe->state, 'read_response');
is($tx3->state, 'read_response');
is($pipe->state, 'read_response');
is($tx3->state, 'read_response');
is(scalar @{$pipe->finished}, 2);
is(scalar @{$pipe->active}, 1);
is(scalar @{$pipe->active}, 1);
is(scalar @{$pipe->inactive}, 0);

0 comments on commit 06ee1a1

Please sign in to comment.