Skip to content

Commit

Permalink
added a few split_header examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 2, 2013
1 parent e56c9c1 commit 084419c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

4.11 2013-06-02
4.11 2013-06-03
- Added allow and append methods to Mojo::Headers.
- Added split_header function to Mojo::Util.
- Fixed small quality detection bug in Mojolicious::Types.
Expand Down
9 changes: 9 additions & 0 deletions lib/Mojo/Util.pm
Expand Up @@ -565,6 +565,15 @@ Read all data at once from file.
Split HTTP header value.
# "one"
split_header('one; two="three four", five=six')->[0][0];
# "three four"
split_header('one; two="three four", five=six')->[0][3];
# "five"
split_header('one; two="three four", five=six')->[1][0];
=head2 spurt
$content = spurt $content, '/etc/passwd';
Expand Down
8 changes: 4 additions & 4 deletions t/mojo/util.t
Expand Up @@ -79,17 +79,17 @@ is_deeply split_header('foo="b,; a\" r\"\\\\"'), [['foo', 'b,; a" r"\\']],
is_deeply split_header('foo = "b a\" r\"\\\\"'), [['foo', 'b a" r"\\']],
'right result';
my $header = q{</foo/bar>; rel="x"; t*=UTF-8'de'a%20b};
my $parsed = [['</foo/bar>', undef, 'rel', 'x', 't*', 'UTF-8\'de\'a%20b']];
is_deeply split_header($header), $parsed, 'right result';
my $tree = [['</foo/bar>', undef, 'rel', 'x', 't*', 'UTF-8\'de\'a%20b']];
is_deeply split_header($header), $tree, 'right result';
$header = 'a=b c; A=b.c; D=/E; a-b=3; F=Thu, 07 Aug 2008 07:07:59 GMT; Ab;';
$parsed = [
$tree = [
['a', 'b', 'c', undef, 'A', 'b.c', 'D', '/E', 'a-b', '3', 'F', 'Thu'],
[
'07', undef, 'Aug', undef, '2008', undef,
'07:07:59', undef, 'GMT', undef, 'Ab', undef
]
];
is_deeply split_header($header), $parsed, 'right result';
is_deeply split_header($header), $tree, 'right result';

# b64_encode
is b64_encode('foobar$%^&3217'), "Zm9vYmFyJCVeJjMyMTc=\n",
Expand Down

0 comments on commit 084419c

Please sign in to comment.