Skip to content

Commit

Permalink
a few more header tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 10, 2016
1 parent a1d482f commit 175e3bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

6.46 2016-02-10
6.46 2016-02-11
- Improved Mojo::Headers performance. (batman)

6.45 2016-02-09
- Deprecated Mojo::Util::xss_escape in favor of Mojo::Util::xml_escape.
Expand Down
15 changes: 11 additions & 4 deletions t/mojo/headers.t
Expand Up @@ -10,8 +10,8 @@ $headers->add(Connection => 'keep-alive');
is $headers->header('Connection'), 'close, keep-alive', 'right value';
$headers->remove('Connection');
is $headers->header('Connection'), undef, 'no value';
$headers->content_type('text/html');
$headers->content_type('text/html');
is $headers->connection, undef, 'no value';
$headers->content_type('text/text')->content_type('text/html');
$headers->expect('continue-100');
$headers->connection('close');
is $headers->content_type, 'text/html', 'right value';
Expand Down Expand Up @@ -202,16 +202,23 @@ is_deeply $headers->to_hash(1),

# Multiple headers with the same name
$headers = Mojo::Headers->new;
$headers->from_hash({'X-Test' => [23, 24], 'X-Test2' => 'foo'});
$headers->from_hash(
{'X-Test' => [23, 24], 'X-Test2' => 'foo', Connection => ['a', 'b']});
$hash = $headers->to_hash;
is $hash->{'X-Test'}, '23, 24', 'right value';
is $hash->{'X-Test2'}, 'foo', 'right value';
is $hash->{Connection}, 'a, b', 'right value';
$hash = $headers->to_hash(1);
is_deeply $hash->{'X-Test'}, [23, 24], 'right structure';
is_deeply $hash->{'X-Test2'}, ['foo'], 'right structure';
is_deeply $hash->{Connection}, ['a', 'b'], 'right structure';
$headers = Mojo::Headers->new->parse($headers->to_string . "\x0d\x0a\x0d\x0a");
is_deeply $headers->to_hash(1), {'X-Test' => [23, 24], 'X-Test2' => ['foo']},
is_deeply $headers->to_hash(1),
{'X-Test' => [23, 24], 'X-Test2' => ['foo'], Connection => ['a', 'b']},
'right structure';
is $headers->header('X-Test'), '23, 24', 'right value';
is $headers->connection, 'a, b', 'right value';
is $headers->connection('c', 'd', 'e')->connection, 'c, d, e', 'right value';

# Headers in chunks
$headers = Mojo::Headers->new;
Expand Down

0 comments on commit 175e3bf

Please sign in to comment.