Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more chunked transfer encoding tests
  • Loading branch information
kraih committed Aug 1, 2012
1 parent 5845030 commit dce8684
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Transaction/WebSocket.pm
Expand Up @@ -521,7 +521,7 @@ Parse WebSocket frame.
my $remote_address = $ws->remote_address;
Alias for C<$ws-E<gt>handshake-E<gt>remove_address>, usually
Alias for C<$ws-E<gt>handshake-E<gt>remote_address>, usually
L<Mojo::Transaction/"remote_address">.
=head2 C<remote_port>
Expand Down
11 changes: 1 addition & 10 deletions t/mojo/request.t
Expand Up @@ -2,7 +2,7 @@ use Mojo::Base -strict;

use utf8;

use Test::More tests => 844;
use Test::More tests => 843;

# "When will I learn?
# The answer to life's problems aren't at the bottom of a bottle,
Expand Down Expand Up @@ -1547,15 +1547,6 @@ is $req->headers->host, '127.0.0.1', 'right "Host" value';
is $req->headers->transfer_encoding, undef, 'no "Transfer-Encoding" value';
is $req->body, "hello world!hello world2!\n\n", 'right content';

# Build HTTP 1.1 chunked request body
$req = Mojo::Message::Request->new;
$req->write_chunk('hello!');
$req->write_chunk('hello world!');
$req->write_chunk('');
is $req->build_body,
"6\x0d\x0ahello!\x0d\x0ac\x0d\x0ahello world!\x0d\x0a0\x0d\x0a\x0d\x0a",
'right format';

# Build full HTTP 1.1 request with cookies
$req = Mojo::Message::Request->new;
$req->method('GET');
Expand Down
15 changes: 13 additions & 2 deletions t/mojo/response.t
@@ -1,6 +1,6 @@
use Mojo::Base -strict;

use Test::More tests => 310;
use Test::More tests => 313;

# "Quick Smithers. Bring the mind eraser device!
# You mean the revolver, sir?
Expand Down Expand Up @@ -257,7 +257,7 @@ is $res->message, 'Internal Server Error', 'right message';
is $res->version, '1.1', 'right version';
is $res->headers->content_type, 'text/plain', 'right "Content-Type" value';
is $res->headers->content_length, 13, 'right "Content-Length" value';
is $res->content->body_size, 13, 'right size';
is $res->body_size, 13, 'right size';

# Parse HTTP 1.1 multipart response
$res = Mojo::Message::Response->new;
Expand Down Expand Up @@ -530,6 +530,17 @@ is $res2->cookie('bar')->value, 'baz', 'right value';
is $res2->cookie('baz')->path, '/foobar', 'right path';
is $res2->cookie('baz')->value, 'yada', 'right value';

# Build chunked response body
$res = Mojo::Message::Response->new;
$res->write_chunk('hello!');
$res->write_chunk('hello world!');
$res->write_chunk('');
ok $res->is_chunked, 'chunked content';
ok $res->is_dynamic, 'dynamic content';
is $res->build_body,
"6\x0d\x0ahello!\x0d\x0ac\x0d\x0ahello world!\x0d\x0a0\x0d\x0a\x0d\x0a",
'right format';

# Build response with callback (make sure it's called)
$res = Mojo::Message::Response->new;
$res->code(200);
Expand Down

0 comments on commit dce8684

Please sign in to comment.