Main.pm 1.71 KB
Newer Older
Yadd's avatar
Yadd committed
1
2
3
# Main FastCGI handler adapter for LLNG handler
#
# See http://lemonldap-ng.org/documentation/latest/handlerarch
Yadd's avatar
Yadd committed
4
5
6
7
package Lemonldap::NG::Handler::Server::Main;

use strict;

Yadd's avatar
Yadd committed
8
9
our $VERSION = '2.0.0';

Yadd's avatar
Yadd committed
10
11
use base 'Lemonldap::NG::Handler::PSGI::Main';

Yadd's avatar
Yadd committed
12
13
use constant defaultLogger => 'Lemonldap::NG::Common::Logger::Syslog';

Yadd's avatar
Yadd committed
14
15
16
17
18
19
20
# In server mode, headers are not passed to a PSGI application but returned
# to the server

## @method void set_header_in(hash headers)
# sets or modifies request headers
# @param headers hash containing header names => header value
sub set_header_in {
21
    my ( $class, $req, %headers ) = @_;
Yadd's avatar
Yadd committed
22
    for my $k ( keys %headers ) {
23
        $req->{env}->{ cgiName($k) } = $headers{$k};
Yadd's avatar
Yadd committed
24
    }
25
    push @{ $req->{respHeaders} }, %headers;
Yadd's avatar
Yadd committed
26
27
28
}

sub unset_header_in {
29
    my ( $class, $req, $header ) = @_;
Yadd's avatar
Yadd committed
30
31
32
    $req->{respHeaders} = [ grep { $_ ne $header and $_ ne cgiName($header) }
          @{ $req->{respHeaders} } ];
    delete $req->{env}->{ cgiName($header) };
Yadd's avatar
Yadd committed
33
    $header =~ s/-/_/g;
34
    delete $req->{env}->{$header};
Yadd's avatar
Yadd committed
35
36
37
38
39
40
41
42
43
44
45
}

# Inheritence is broken in this case with Debian >= jessie
*checkType          = *Lemonldap::NG::Handler::PSGI::Main::checkType;
*setServerSignature = *Lemonldap::NG::Handler::PSGI::Main::setServerSignature;
*thread_share       = *Lemonldap::NG::Handler::PSGI::Main::thread_share;
*set_user           = *Lemonldap::NG::Handler::PSGI::Main::set_user;
*set_header_out     = *Lemonldap::NG::Handler::PSGI::Main::set_header_out;
*is_initial_req     = *Lemonldap::NG::Handler::PSGI::Main::is_initial_req;
*print              = *Lemonldap::NG::Handler::PSGI::Main::print;
*addToHtmlHead      = *Lemonldap::NG::Handler::PSGI::Main::addToHtmlHead;
46
*cgiName            = *Lemonldap::NG::Handler::PSGI::Main::cgiName;
Yadd's avatar
Yadd committed
47
1;