102 |
warn "<<<< ", $sock->peerhost, " [" . localtime() . "] ", $r->method, " ", $r->uri, " $size bytes\n"; |
warn "<<<< ", $sock->peerhost, " [" . localtime() . "] ", $r->method, " ", $r->uri, " $size bytes\n"; |
103 |
|
|
104 |
if ( $self->debug > 2 ) { |
if ( $self->debug > 2 ) { |
105 |
my $file = sprintf("dump/%04d.request", $dump_nr); |
my $file = sprintf("dump/%04d-%s.request", $dump_nr++, $sock->peerhost); |
106 |
write_file( $file, $r->as_string ); |
write_file( $file, $r->as_string ); |
107 |
warn "### request dump: $file\n"; |
warn "### request dump: $file\n"; |
108 |
} |
} |
113 |
|
|
114 |
die "no SOAPAction header in ",dump($chunk) unless defined ( $r->header('SOAPAction') ); |
die "no SOAPAction header in ",dump($chunk) unless defined ( $r->header('SOAPAction') ); |
115 |
|
|
116 |
|
$state = CWMP::Request->parse( $chunk ); |
117 |
|
|
118 |
if ( $chunk ) { |
warn "## acquired state = ", dump( $state ), "\n"; |
|
warn "## request chunk: ",length($chunk)," bytes\n$chunk\n" if $self->debug; |
|
119 |
|
|
120 |
$state = CWMP::Request->parse( $chunk ); |
$self->state( $state ); |
121 |
|
$self->store->update_state( ID => $state->{ID}, $state ); |
122 |
|
|
123 |
warn "## acquired state = ", dump( $state ), "\n"; |
} else { |
|
|
|
|
$self->state( $state ); |
|
|
$self->store->update_state( ID => $state->{ID}, $state ); |
|
124 |
|
|
125 |
} else { |
warn "## empty request\n"; |
|
warn "## empty request\n"; |
|
|
} |
|
126 |
|
|
|
} else { |
|
127 |
$state = $self->state; |
$state = $self->state; |
128 |
|
delete( $state->{_dispatch} ); |
129 |
warn "last request state = ", dump( $state ), "\n" if $self->debug > 1; |
warn "last request state = ", dump( $state ), "\n" if $self->debug > 1; |
130 |
} |
} |
131 |
|
|
184 |
my $xml = $response->$dispatch( $self->state, @_ ); |
my $xml = $response->$dispatch( $self->state, @_ ); |
185 |
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug; |
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug; |
186 |
if ( $self->debug > 2 ) { |
if ( $self->debug > 2 ) { |
187 |
my $file = sprintf("dump/%04d.response", $dump_nr++); |
my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost); |
188 |
write_file( $file, $xml ); |
write_file( $file, $xml ); |
189 |
warn "### response dump: $file\n"; |
warn "### response dump: $file\n"; |
190 |
} |
} |