Skip to content

Commit

Permalink
reduced number of headers to 100
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 11, 2015
1 parent 45e94c4 commit 15eaed0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/Mojo/Headers.pm
Expand Up @@ -4,7 +4,7 @@ use Mojo::Base -base;
use Mojo::Util 'monkey_patch';

has max_line_size => sub { $ENV{MOJO_MAX_LINE_SIZE} || 10240 };
has max_lines => sub { $ENV{MOJO_MAX_LINES} || 128 };
has max_lines => sub { $ENV{MOJO_MAX_LINES} || 100 };

# Common headers
my %NORMALCASE = map { lc($_) => $_ } (
Expand Down Expand Up @@ -189,10 +189,10 @@ C<MOJO_MAX_LINE_SIZE> environment variable or C<10240> (10KB).
=head2 max_lines
my $num = $headers->max_lines;
$headers = $headers->max_lines(256);
$headers = $headers->max_lines(200);
Maximum number of header lines, defaults to the value of the C<MOJO_MAX_LINES>
environment variable or C<128>.
environment variable or C<100>.
=head1 METHODS
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Guides/FAQ.pod
Expand Up @@ -151,7 +151,7 @@ C<MOJO_MAX_LINE_SIZE> environment variable to change this value.

Almost the same as the previous answer, but this protection mechanism limits
the number and maximum length of HTTP request and response headers. The limits
are 128 headers with 10KB each by default, you can use the attributes
are 100 headers with 10KB each by default, you can use the attributes
L<Mojo::Headers/"max_lines"> and L<Mojo::Headers/"max_line_size"> or the
C<MOJO_MAX_LINES> and C<MOJO_MAX_LINE_SIZE> environment variables to change
these values.
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/request.t
Expand Up @@ -33,7 +33,7 @@ is $req->cookie('a'), undef, 'no value';
# Parse HTTP 1.1 message with huge "Cookie" header exceeding line limit
$req = Mojo::Message::Request->new;
is $req->headers->max_line_size, 10240, 'right size';
is $req->headers->max_lines, 128, 'right number';
is $req->headers->max_lines, 100, 'right number';
$req->parse("GET / HTTP/1.1\x0d\x0a");
$req->parse("Cookie: @{['a=b; ' x 131072]}\x0d\x0a");
$req->parse("Content-Length: 0\x0d\x0a\x0d\x0a");
Expand Down Expand Up @@ -100,7 +100,7 @@ is $req->body, '', 'no content';
# Parse broken HTTP 1.1 message with start-line exceeding line limit
$req = Mojo::Message::Request->new;
is $req->max_line_size, 10240, 'right size';
is $req->headers->max_lines, 128, 'right number';
is $req->headers->max_lines, 100, 'right number';
$req->parse("GET /@{['abcd' x 131072]} HTTP/1.1");
ok $req->is_finished, 'request is finished';
is $req->error->{message}, 'Maximum start-line size exceeded', 'right error';
Expand Down

0 comments on commit 15eaed0

Please sign in to comment.