File: headers_psgi_flatten.t

package info (click to toggle)
libhttp-headers-fast-perl 0.22-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 176 kB
  • sloc: perl: 1,036; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,650 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!perl -w

use strict;
use Test::More tests => 12;
require HTTP::Headers::Fast;


my $h = HTTP::Headers::Fast->new;
is_deeply($h->psgi_flatten, []);

$h = HTTP::Headers::Fast->new(foo => "bar", foo => "baaaaz", Foo => "baz");
is_deeply($h->psgi_flatten, ['Foo','bar','Foo','baaaaz','Foo','baz']);
is_deeply($h->psgi_flatten_without_sort, ['Foo','bar','Foo','baaaaz','Foo','baz']);

$h = HTTP::Headers::Fast->new(foo => ["bar", "baz"]);
is_deeply($h->psgi_flatten, ['Foo','bar','Foo','baz']);

$h = HTTP::Headers::Fast->new(foo => 1, bar => 2, foo_bar => 3);
is_deeply($h->psgi_flatten, ['Bar','2','Foo','1','Foo-Bar','3']);


$h = HTTP::Headers::Fast->new(
    a => "foo\r\n\r\nevil body" ,
    b => "foo\015\012\015\012evil body" ,
    c => "foo\x0d\x0a\x0d\x0aevil body" ,
);
is_deeply($h->psgi_flatten, [
    'A', "fooevil body",
    'B', "fooevil body",
    'C', "fooevil body",
    ]);

$h = HTTP::Headers::Fast->new(
    "Foo\000Bar" => "baz",
    "Qux\177Quux" => "42"
);
is_deeply($h->psgi_flatten, [ "Foo\000Bar" => 'baz', "Qux\177Quux" => '42' ]);
is_deeply(+{@{$h->psgi_flatten_without_sort}}, +{ "Foo\000Bar" => 'baz', "Qux\177Quux" => '42' });

$h = HTTP::Headers::Fast->new(
    "X-LWS-I"  => "Bar\r\n  true",
    "X-LWS-II" => "Bar\r\n\t\ttrue"
);
is_deeply($h->psgi_flatten, [ 'X-LWS-I' => 'Bar true', 'X-LWS-II' => 'Bar true' ]);
is_deeply(+{@{$h->psgi_flatten_without_sort}}, +{ 'X-LWS-I' => 'Bar true', 'X-LWS-II' => 'Bar true' });

$h = HTTP::Headers::Fast->new(
    "X-CR-LF" => "Foo\nBar\rBaz"
);
is_deeply($h->psgi_flatten, [ 'X-CR-LF' => 'FooBarBaz' ]);
is_deeply($h->psgi_flatten_without_sort, [ 'X-CR-LF' => 'FooBarBaz' ]);