| 1 | package VUser::SOAP::Transport::HTTP; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | |||
| 5 | # Copyright (c) 2006 Randy Smith | ||
| 6 | # $Id: HTTP.pm,v 1.2 2006/09/28 17:32:58 perlstalker Exp $ | ||
| 7 | |||
| 8 | use VUser::ExtLib qw(:config); | ||
| 9 | use VUser::Log qw(:levels); | ||
| 10 | use SOAP::Transport::HTTP; | ||
| 11 | |||
| 12 | my $c_sec = 'vsoapd HTTP'; | ||
| 13 | my $log; | ||
| 14 | |||
| 15 | sub new { | ||
| 16 | my $class = shift; | ||
| 17 | my $cfg = shift; | ||
| 18 | my %passed_opts = @_; | ||
| 19 | |||
| 20 | if (ref $main::log and UNIVERSAL::isa($main::log, 'VUser::Log')) { | ||
| 21 | $log = $main::log; | ||
| 22 | } else { | ||
| 23 | $log = VUser::Log->new ($cfg, 'vsoapd/http'); | ||
| 24 | } | ||
| 25 | |||
| 26 | my $port = strip_ws($cfg->{$c_sec}{port}); | ||
| 27 | my $address = strip_ws($cfg->{$c_sec}{address}); | ||
| 28 | |||
| 29 | my %daemon_opts = ('LocalPort' => $port, Reuse => 1); | ||
| 30 | if ($address) { | ||
| 31 | $daemon_opts{'LocalAddress'} = $address; | ||
| 32 | } | ||
| 33 | |||
| 34 | foreach my $key (keys %passed_opts) { | ||
| 35 | if (not defined $daemon_opts{$key}) { | ||
| 36 | $daemon_opts{$key} = $passed_opts{$key}; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | $log->log(LOG_NOTICE, "Starting HTTP on port $port%s", | ||
| 41 | ($address ? " at $address" : '') | ||
| 42 | ); | ||
| 43 | my $daemon = SOAP::Transport::HTTP::Daemon->new (%daemon_opts); | ||
| 44 | return $daemon; | ||
| 45 | } | ||
| 46 | |||
| 47 | 1; | ||
| 48 | |||
| 49 | __END__ |