Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added a few more message size limit tests
  • Loading branch information
kraih committed Oct 6, 2011
1 parent b9c0e6d commit 132e972
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions t/mojo/message.t
Expand Up @@ -3,7 +3,7 @@ use Mojo::Base -strict;

use utf8;

use Test::More tests => 1203;
use Test::More tests => 1213;

use File::Spec;
use File::Temp;
Expand Down Expand Up @@ -241,7 +241,7 @@ is $req->url, '/foo/bar/baz.html', 'right URL';
is $req->headers->content_type, 'text/plain', 'right "Content-Type" value';
is $req->headers->content_length, undef, 'no "Content-Length" value';

# Parse HTTP 1.0 start line and headers, no body (with line size limit)
# Parse HTTP 1.0 start line (with line size limit)
$req = Mojo::Message::Request->new;
$backup = $ENV{MOJO_MAX_LINE_SIZE} || '';
$ENV{MOJO_MAX_LINE_SIZE} = 5;
Expand All @@ -251,12 +251,48 @@ is(($req->error)[0], 'Maximum line size exceeded.', 'right error');
is(($req->error)[1], 413, 'right status');
$ENV{MOJO_MAX_LINE_SIZE} = $backup;

# Parse HTTP 1.0 start line and headers, no body (with message size limit)
# Parse HTTP 1.0 start line and headers (with line size limit)
$req = Mojo::Message::Request->new;
$backup = $ENV{MOJO_MAX_LINE_SIZE} || '';
$ENV{MOJO_MAX_LINE_SIZE} = 20;
$req->parse("GET / HTTP/1.0\x0d\x0a");
$req->parse("Content-Type: text/plain\x0d\x0a");
ok $req->is_done, 'request is done';
is(($req->error)[0], 'Maximum line size exceeded.', 'right error');
is(($req->error)[1], 413, 'right status');
$ENV{MOJO_MAX_LINE_SIZE} = $backup;

# Parse HTTP 1.0 start line (with message size limit)
$req = Mojo::Message::Request->new;
$backup = $ENV{MOJO_MAX_MESSAGE_SIZE} || '';
$ENV{MOJO_MAX_MESSAGE_SIZE} = 5;
$req->parse('GET /foo/bar/baz.html HTTP/1');
ok $req->is_done, 'request is done';
is(($req->error)[0], 'Maximum message size exceeded.', 'right error');
is(($req->error)[1], 413, 'right status');
$ENV{MOJO_MAX_MESSAGE_SIZE} = $backup;

# Parse HTTP 1.0 start line and headers (with message size limit)
$req = Mojo::Message::Request->new;
$backup = $ENV{MOJO_MAX_MESSAGE_SIZE} || '';
$ENV{MOJO_MAX_MESSAGE_SIZE} = 20;
$req->parse("GET / HTTP/1.0\x0d\x0a");
$req->parse("Content-Type: text/plain\x0d\x0a");
ok $req->is_done, 'request is done';
is(($req->error)[0], 'Maximum message size exceeded.', 'right error');
is(($req->error)[1], 413, 'right status');
$ENV{MOJO_MAX_MESSAGE_SIZE} = $backup;

# Parse HTTP 1.0 start line, headers and body (with message size limit)
$req = Mojo::Message::Request->new;
$backup = $ENV{MOJO_MAX_MESSAGE_SIZE} || '';
$ENV{MOJO_MAX_MESSAGE_SIZE} = 50;
$req->parse("GET / HTTP/1.0\x0d\x0a");
$req->parse("Content-Length: 24\x0d\x0a\x0d\x0a");
$req->parse('Hello World!');
$req->parse('Hello World!');
ok $req->is_done, 'request is done';
is(($req->error)[0], 'Maximum message size exceeded.', 'right error');
is(($req->error)[1], 413, 'right status');
$ENV{MOJO_MAX_MESSAGE_SIZE} = $backup;

Expand Down

0 comments on commit 132e972

Please sign in to comment.