148 |
|
|
149 |
my $size = length( $chunk ); |
my $size = length( $chunk ); |
150 |
|
|
151 |
warn "<<< " . $sock->peerhost . " [" . localtime() . "] request $size bytes\n"; |
warn "<<<< " . $sock->peerhost . " [" . localtime() . "] request $size bytes\n"; |
152 |
|
|
153 |
my $state; |
my $state; |
154 |
|
|
162 |
|
|
163 |
$state = CWMP::Request->parse( $chunk ); |
$state = CWMP::Request->parse( $chunk ); |
164 |
|
|
165 |
warn "acquired state = ", dump( $state ), "\n"; |
warn "## acquired state = ", dump( $state ), "\n"; |
166 |
|
|
167 |
$self->state( $state ); |
$self->state( $state ); |
168 |
|
|
169 |
} else { |
} else { |
170 |
warn "empty request\n"; |
warn "## empty request\n"; |
171 |
} |
} |
172 |
|
|
173 |
} else { |
} else { |
203 |
$sock->send( "Content-Length: " . length( $xml ) . "\r\n\r\n" ); |
$sock->send( "Content-Length: " . length( $xml ) . "\r\n\r\n" ); |
204 |
$sock->send( $xml ) or die "can't send response"; |
$sock->send( $xml ) or die "can't send response"; |
205 |
|
|
206 |
warn "### request over"; |
warn ">>>> " . $sock->peerhost . " [" . localtime() . "] sent ", length( $xml )," bytes\n"; |
207 |
|
|
208 |
|
warn "### request over\n" if $self->debug; |
209 |
|
|
210 |
|
return 1; # next request |
211 |
}; |
}; |
212 |
|
|
213 |
=head2 dispatch |
=head2 dispatch |
225 |
|
|
226 |
if ( $response->can( $dispatch ) ) { |
if ( $response->can( $dispatch ) ) { |
227 |
warn ">>> dispatching to $dispatch\n"; |
warn ">>> dispatching to $dispatch\n"; |
228 |
my $xml = $response->$dispatch( $self->state, @_ ) . "\r\n"; |
my $xml = $response->$dispatch( $self->state, @_ ); |
229 |
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug; |
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug; |
230 |
return $xml; |
return $xml; |
231 |
} else { |
} else { |