--- google/lib/CWMP/Server.pm 2007/06/19 17:29:07 40 +++ google/lib/CWMP/Server.pm 2007/06/19 18:11:37 41 @@ -8,6 +8,7 @@ __PACKAGE__->mk_accessors( qw/ debug port +sock / ); use IO::Socket::INET; @@ -51,6 +52,7 @@ warn "connection from ", $sock->peerhost, "\n"; + $self->sock( $sock ); # FIXME this will not work for multiple clients $self->process_request( $sock ); warn "...another one bites a dust...\n"; @@ -142,11 +144,14 @@ my $response = CWMP::Response->new({ debug => $self->debug }); - print $self->status(200), $self->content_type('text/xml; charset="utf-8"'), "\r\n"; - - print "Server: AcmeCWMP/42\r\nSOAPServer: AcmeCWMP/42\r\n"; + $sock->print( + $self->status(200), + $self->content_type('text/xml; charset="utf-8"'), + "Server: AcmeCWMP/42\r\n", + "SOAPServer: AcmeCWMP/42\r\n" + ); - print "Set-Cookie: ID=" , $state->{ID}, "; path=/\r\n" if ( $state->{ID} ); + $sock->print( "Set-Cookie: ID=" , $state->{ID}, "; path=/\r\n" ) if ( $state->{ID} ); my $xml = ''; @@ -162,8 +167,8 @@ warn ">>> empty response\n"; } - print "Content-length: ", length( $xml ), "\r\n\r\n"; - print $xml or die "can't send response"; + $sock->print( "Content-length: ", length( $xml ), "\r\n\r\n" ); + $sock->print( $xml ) or die "can't send response"; warn "### request over"; @@ -206,7 +211,7 @@ sub error{ my ($self, $number, $msg) = @_; - print $self->status($number, $msg), "\r\n"; + $self->sock->print( $self->status($number, $msg), "\r\n" ); warn "Error - $number - $msg\n"; } @@ -221,7 +226,7 @@ my $self = shift; my $number = shift || 200; return if ! delete $self->{needs_header}; - print "HTTP/1.0 $number\r\n"; + $self->sock->Print("HTTP/1.0 $number\r\n"); return 1; }