File: err_headers_out.t

package info (click to toggle)
libapache2-mod-perl2 2.0.13-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 12,016 kB
  • sloc: perl: 97,771; ansic: 14,493; makefile: 51; sh: 18
file content (61 lines) | stat: -rw-r--r-- 2,000 bytes parent folder | download | duplicates (7)
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
52
53
54
55
56
57
58
59
60
61
# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil;

plan tests => 6, need 'HTML::HeadParser';

my $location = '/TestAPI__err_headers_out';

{
    # with 2xx responses any of the err_headers_out and headers_out
    # headers make it through

    my $res = GET "$location?200";

    #t_debug $res->as_string;

    ok t_cmp $res->code, 200, "OK";

    # HTTP::Headers 6.00 makes the next 2 tests fail. When the response comes
    # in the header name is stored as "x-err_headers_out". But when it is to
    # be read below it is referred as "x-err-headers-out" and hence not found.
    local $HTTP::Headers::TRANSLATE_UNDERSCORE=
	$HTTP::Headers::TRANSLATE_UNDERSCORE;
    undef $HTTP::Headers::TRANSLATE_UNDERSCORE
	if defined HTTP::Headers->VERSION and HTTP::Headers->VERSION >= 6.00;

    ok t_cmp $res->header('X-err_headers_out'), "err_headers_out",
        "X-err_headers_out: made it";

    ok t_cmp $res->header('X-headers_out'), "headers_out",
        "X-headers_out: made it";
}

{
    # with non-2xx responses only the err_headers_out headers make it
    # through. the headers_out do not make it.

    my $res = GET "$location?404";

    #t_debug $res->as_string;

    ok t_cmp $res->code, 404, "not found";

    # HTTP::Headers 6.00 makes this test fail. When the response comes in
    # the header name is stored as "x-err_headers_out". But when it is to
    # be read below it is referred as "x-err-headers-out" and hence not found.
    local $HTTP::Headers::TRANSLATE_UNDERSCORE=
	$HTTP::Headers::TRANSLATE_UNDERSCORE;
    undef $HTTP::Headers::TRANSLATE_UNDERSCORE
	if defined HTTP::Headers->VERSION and HTTP::Headers->VERSION >= 6.00;

    ok t_cmp $res->header('X-err_headers_out'), "err_headers_out",
        "X-err_headers_out: made it";

    ok !$res->header('X-headers_out');
}