File: 500.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 (91 lines) | stat: -rw-r--r-- 2,350 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# 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::TestUtil;
use Apache::TestRequest qw(GET);

plan tests => 7, need 'mod_alias.c';

{
    # the script changes the status before the run-time error happens,
    # this status change should be ignored
    my $url = "/registry/runtime_error_n_status_change.pl";
    my $res = GET($url);
    #t_debug($res->content);
    ok t_cmp(
        $res->code,
        500,
        "500 error on runtime error (when the script changes the status)",
       );
}

{
    my $url = "/registry/syntax_error.pl";
    my $res = GET($url);
    #t_debug($res->content);
    ok t_cmp(
        $res->code,
        500,
        "500 compile time error (syntax error)",
       );
}

{
    my $url = "/registry/use_error.pl";
    my $res = GET($url);
    #t_debug($res->content);
    ok t_cmp(
        $res->code,
        500,
        "500 compile error on use() failure",
       );
}

{
    my $url = "/registry/missing_headers.pl";
    my $res = GET($url);
    #t_debug($res->content);
    ok t_cmp(
        $res->code,
        500,
        "500 error on missing HTTP headers",
       );
}

{
    # since we have a runtime error before any body is sent, mod_perl
    # has a chance to communicate the return status of the script to
    # Apache before headers are sent, so we get the code 500 in the
    # HTTP headers
    my $url = "/registry/runtime_error.pl";
    my $res = GET($url);
    #t_debug($res->content);
    ok t_cmp(
        $res->code,
        500,
        "500 error on runtime error",
       );
}

{
    # even though we have a runtime error here, the scripts succeeds
    # to send some body before the error happens and since by that
    # time Apache has already sent the headers, they will include 
    # 200 OK
    my $url = "/registry/runtime_error_plus_body.pl";
    my $res = GET($url);
    #t_debug($res->content);
    ok t_cmp(
        $res->code,
        200,
        "200, followed by a runtime error",
       );

    # the error message is attached after the body
    ok t_cmp($res->content,
             qr/some body.*The server encountered an internal error/ms,
             "200, followed by a runtime error",
            );
}