File: err_headers_out.pm

package info (click to toggle)
libapache2-mod-perl2 2.0.9~1624218-2%2Bdeb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 11,912 kB
  • ctags: 4,588
  • sloc: perl: 95,064; ansic: 14,527; makefile: 49; sh: 18
file content (31 lines) | stat: -rw-r--r-- 849 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
# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
package TestAPI::err_headers_out;

# tests: $r->err_headers_out

# when sending a non-2xx response one must use $r->err_headers_out to
# set extra headers

use strict;
use warnings FATAL => 'all';

use Apache2::RequestRec ();
use Apache2::RequestUtil ();
use APR::Table ();

use Apache2::Const -compile => qw(OK NOT_FOUND);

sub handler {
    my $r = shift;

    # this header will always make it to the client
    $r->err_headers_out->add('X-err_headers_out' => "err_headers_out");

    # this header will make it to the client only on 2xx response
    $r->headers_out->add('X-headers_out' => "headers_out");

    return $r->args eq "404" ? Apache2::Const::NOT_FOUND : Apache2::Const::OK;
}

1;
__END__