File: 015_parse_http_headers.t

package info (click to toggle)
libyahc-perl 0.035-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 440 kB
  • sloc: perl: 3,661; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 878 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use YAHC;

my $CRLF = "\x0d\x0a";

my @test_cases = (
    [
        join($CRLF,
            'HTTP/1.1 200 OK',
            'Date: Sat, 23 Nov 2013 23:10:28 GMT',
            'Last-Modified: Sat, 26 Oct 2013 19:41:47 GMT',
            'ETag: "4b9d0211dd8a2819866bccff777af225"',
            'Content-Type: text/html',
            'Server: Example',
            'Content-Length: 4'
        ),
        {
            "date" => "Sat, 23 Nov 2013 23:10:28 GMT",
            "last-modified" => "Sat, 26 Oct 2013 19:41:47 GMT",
            "etag" => '"4b9d0211dd8a2819866bccff777af225"',
            "content-type" => "text/html",
            "content-length" => "4",
            "server" => "Example",
        },
    ]
);

is_deeply( YAHC::_parse_http_headers({}, $_->[0]), $_->[1])
    foreach @test_cases;

done_testing;