--- google/lib/CWMP/Server.pm 2007/06/19 00:18:56 35 +++ google/lib/CWMP/Server.pm 2007/06/19 00:38:49 36 @@ -12,6 +12,7 @@ use Data::Dump qw/dump/; use CWMP::Request; use CWMP::Response; +use Carp qw/confess/; =head1 NAME @@ -76,24 +77,37 @@ #... do something, print output to default # selected filehandle... - warn ">> " . localtime() . " " . $ENV{REMOTE_ADDR} . "\n"; + warn "<<< " . localtime() . " " . $ENV{REMOTE_ADDR} . "\n"; warn "not SOAP request" unless defined ( $cgi->header('SOAPAction') ); + my $state; + if ( my $payload = $cgi->param('POSTDATA') ) { warn "request payload:\n$payload\n" if $self->debug; - my $state = CWMP::Request->parse( $payload ); + $state = CWMP::Request->parse( $payload ); warn "acquired state = ", dump( $state ); + } else { + warn "empty request\n"; } my $response = CWMP::Response->new({ debug => $self->debug }); print "Content-Type: text/xml\r\n\r\n"; - print $response->Inform; + if ( my $dispatch = $state->{_dispatch} ) { + if ( $response->can( $dispatch ) ) { + warn ">>> dispatching to $dispatch\n"; + print $response->$dispatch; + } else { + confess "can't dispatch to $dispatch"; + } + } else { + warn ">>> empty response\n"; + } };