From 7b228b78e7b84172c1180c463c38f187d1ce496e Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 7 Mar 2010 12:01:34 +0000 Subject: [PATCH] 3.4.6 Additional HTTP Requirements Whenever the ACS sends an empty HTTP response, it MUST use the "204 (No Content)" HTTP status code. git-svn-id: https://perl-cwmp.googlecode.com/svn/trunk@255 836a5e1a-633d-0410-964b-294494ad4392 --- lib/CWMP/Session.pm | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/CWMP/Session.pm b/lib/CWMP/Session.pm index 25dd084..ce43cb3 100644 --- a/lib/CWMP/Session.pm +++ b/lib/CWMP/Session.pm @@ -114,15 +114,6 @@ sub process_request { #warn "last request state = ", dump( $state ), "\n" if $self->debug > 1; } - my $out = join("\r\n", - 'HTTP/1.1 200 OK', - 'Content-Type: text/xml; charset="utf-8"', - 'Server: Perl-CWMP/42', - 'SOAPServer: Perl-CWMP/42' - ) . "\r\n"; - - $out .= "Set-Cookie: ID=" . $state->{ID} . "; path=/\r\n" if $state->{ID}; - my $uid = $self->store->state_to_uid( $state ); my $to_uid = join(" ", grep { defined($_) } "to $uid", @@ -138,23 +129,33 @@ sub process_request { id => $uid, debug => $self->debug, }); - my $job; $xml = ''; if ( my $dispatch = $state->{_dispatch} ) { $xml = $self->dispatch( $dispatch ); - } elsif ( $job = $queue->dequeue ) { + } elsif ( my $job = $queue->dequeue ) { $xml = $self->dispatch( $job->dispatch ); + $job->finish; } else { warn ">>> empty response $to_uid"; $state->{NoMoreRequests} = 1; $xml = ''; } + my $status = length($xml) ? 200 : 204; + + my $out = join("\r\n", + "HTTP/1.1 $status OK", + 'Content-Type: text/xml; charset="utf-8"', + 'Server: Perl-CWMP/42', + 'SOAPServer: Perl-CWMP/42' + ) . "\r\n"; + + $out .= "Set-Cookie: ID=" . $state->{ID} . "; path=/\r\n" if $state->{ID}; + $out .= "Content-Length: " . length( $xml ) . "\r\n\r\n"; $out .= $xml if length($xml); - $job->finish if $job; warn "### request over for $uid\n" if $self->debug; return $out; # next request -- 2.20.1