--- google/lib/CWMP/Server.pm 2007/06/19 21:35:35 51 +++ google/lib/CWMP/Server.pm 2007/06/20 20:24:34 54 @@ -47,12 +47,14 @@ ReuseAddr => 1, ); - warn "ACS waiting for request on port ", $self->port, " queue ( ", join(",",@{$self->queue}), " )\n"; + warn "ACS waiting for request on port ", $self->port, + $self->queue ? " queue ( " . join(",",@{$self->queue}) . " )" : "", + "\n"; while ( my $sock = $listen->accept ) { $sock->autoflush(1); - warn "connection from ", $sock->peerhost, "\n"; + warn "connection from ", $sock->peerhost, "\n" if $self->debug; $self->sock( $sock ); # FIXME this will not work for multiple clients while ( $self->process_request ) { @@ -79,7 +81,7 @@ die "not IO::Socket::INET but ", ref( $sock ) unless ( ref($sock) eq 'IO::Socket::INET' ); if ( ! $sock->connected ) { - warn "SOCKET NOT CONNECTED"; + warn "SOCKET NOT CONNECTED\n"; return 0; } @@ -132,7 +134,7 @@ $sock->read( my $buff, $len ); $chunk .= $buff; - warn "--- $len bytes: --=>||$buff||<=--\n"; + warn "--- $len bytes: --=>||$buff||<=--\n" if $self->debug; } while ( $len > 0 ); my $sep = $sock->getline; @@ -177,7 +179,7 @@ 'Content-Type: text/xml; charset="utf-8"', 'Server: AcmeCWMP/42', 'SOAPServer: AcmeCWMP/42' - )); + )."\r\n"); $sock->send( "Set-Cookie: ID=" . $state->{ID} . "; path=/\r\n" ) if ( $state->{ID} ); @@ -219,7 +221,7 @@ if ( $response->can( $dispatch ) ) { warn ">>> dispatching to $dispatch\n"; my $xml = $response->$dispatch( $self->state, @_ ) . "\r\n"; - warn "## response payload: ",length($xml)," bytes\n$xml\n"; + warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug; return $xml; } else { confess "can't dispatch to $dispatch"; @@ -240,7 +242,7 @@ while (defined($_ = $self->sock->getline)) { s/[\r\n]+$//; last unless length $_; - warn "-- $_\n"; + warn "-- $_\n" if $self->debug; return 0 if ! /^ ([\w\-]+) :[\ \t]* (.*) $/x; $self->{headers}->{$1} = $2; }