File: err_headers_out.pm

package info (click to toggle)
libapache2-mod-perl2 2.0.4-7%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 9,896 kB
  • ctags: 3,820
  • sloc: perl: 56,663; ansic: 14,001; makefile: 93; sh: 38
file content (30 lines) | stat: -rw-r--r-- 704 bytes parent folder | download | duplicates (4)
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
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__