Commit bf6450df authored by Yadd's avatar Yadd
Browse files

LEMONLDAP::NG : Split CGI and SOAP functions

parent b5b22791
......@@ -3,6 +3,7 @@ lib/Lemonldap/NG/Common.pm
lib/Lemonldap/NG/Common/Apache/Session.pm
lib/Lemonldap/NG/Common/Apache/Session/SOAP.pm
lib/Lemonldap/NG/Common/CGI.pm
lib/Lemonldap/NG/Common/CGI/SOAPServer.pm
lib/Lemonldap/NG/Common/Conf.pm
lib/Lemonldap/NG/Common/Conf/Constants.pm
lib/Lemonldap/NG/Common/Conf/DBI.pm
......@@ -19,6 +20,7 @@ t/02-Common-Conf-File.t
t/03-Common-Conf-DBI.t
t/04-Common-Conf-SOAP.t
t/10-Common.t
t/20-Common-CGI.t
t/99-pod.t
tools/apache-session-mysql.sql
tools/lmConfig.mysql
......@@ -13,6 +13,7 @@ requires:
DBI: 0
Regexp::Assemble: 0
Storable: 0
SOAP::Lite: 0
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3
......@@ -23,6 +23,7 @@ sub soapTest {
# If non form encoded datas are posted, we call SOAP Services
if ( $ENV{HTTP_SOAPACTION} ) {
require Lemonldap::NG::Common::CGI::SOAPServer;
my @func = ();
foreach ( ref($soapFunctions) ? @$soapFunctions : split /\s+/, $soapFunctions ) {
$_ = ref($self) . "::$_" unless (/::/);
......@@ -97,69 +98,6 @@ sub abort {
exit;
}
package Lemonldap::NG::Common::CGI::SOAPServer;
use SOAP::Transport::HTTP;
use base 'SOAP::Transport::HTTP::Server';
sub DESTROY { SOAP::Trace::objects('()') }
sub new {
my $self = shift;
return $self if ref $self;
my $class = ref($self) || $self;
$self = $class->SUPER::new(@_);
SOAP::Trace::objects('()');
return $self;
}
sub handle {
my $self = shift->new;
my $cgi = shift;
my $content = $cgi->param('POSTDATA');
my $length = length($content);
if ( !$length ) {
$self->response( HTTP::Response->new(411) ) # LENGTH REQUIRED
}
elsif ( defined $SOAP::Constants::MAX_CONTENT_SIZE
&& $length > $SOAP::Constants::MAX_CONTENT_SIZE )
{
$self->response( HTTP::Response->new(413) ) # REQUEST ENTITY TOO LARGE
}
else {
$self->request(
HTTP::Request->new(
'POST' => $ENV{'SCRIPT_NAME'},
HTTP::Headers->new(
map {
(
/^HTTP_(.+)/i
? ( $1 =~ m/SOAPACTION/ )
? ('SOAPAction')
: ($1)
: $_
) => $ENV{$_}
} keys %ENV
),
$content,
)
);
$self->SUPER::handle;
}
print $cgi->header(
-status => $self->response->code . " "
. HTTP::Status::status_message( $self->response->code ),
-type => $self->response->header('Content-Type'),
-Content_Length => $self->response->header('Content-Length'),
-SOAPServer => 'Lemonldap::NG CGI',
);
print $self->response->content;
}
1;
__END__
......
package Lemonldap::NG::Common::CGI::SOAPServer;
use SOAP::Transport::HTTP;
use base 'SOAP::Transport::HTTP::Server';
sub DESTROY { SOAP::Trace::objects('()') }
sub new {
my $self = shift;
return $self if ref $self;
my $class = ref($self) || $self;
$self = $class->SUPER::new(@_);
SOAP::Trace::objects('()');
return $self;
}
sub handle {
my $self = shift->new;
my $cgi = shift;
my $content = $cgi->param('POSTDATA');
my $length = length($content);
if ( !$length ) {
$self->response( HTTP::Response->new(411) ) # LENGTH REQUIRED
}
elsif ( defined $SOAP::Constants::MAX_CONTENT_SIZE
&& $length > $SOAP::Constants::MAX_CONTENT_SIZE )
{
$self->response( HTTP::Response->new(413) ) # REQUEST ENTITY TOO LARGE
}
else {
$self->request(
HTTP::Request->new(
'POST' => $ENV{'SCRIPT_NAME'},
HTTP::Headers->new(
map {
(
/^HTTP_(.+)/i
? ( $1 =~ m/SOAPACTION/ )
? ('SOAPAction')
: ($1)
: $_
) => $ENV{$_}
} keys %ENV
),
$content,
)
);
$self->SUPER::handle;
}
print $cgi->header(
-status => $self->response->code . " "
. HTTP::Status::status_message( $self->response->code ),
-type => $self->response->header('Content-Type'),
-Content_Length => $self->response->header('Content-Length'),
-SOAPServer => 'Lemonldap::NG CGI',
);
print $self->response->content;
}
1;
__END__
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment