/[cwmp]/google/trunk/lib/CWMP/Session.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /google/trunk/lib/CWMP/Session.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 47 by dpavlin, Tue Jun 19 19:09:16 2007 UTC revision 48 by dpavlin, Tue Jun 19 20:02:36 2007 UTC
# Line 61  sub run { Line 61  sub run {
61          }          }
62  }  }
63    
64    =head2 process_request
65    
66    One request from client/response from server cycle. Call multiple times to
67    facilitate brain-dead concept of adding state to stateless protocol like
68    HTTP.
69    
70    =cut
71    
72  sub process_request {  sub process_request {
73          my $self = shift;          my $self = shift;
74    
# Line 77  sub process_request { Line 85  sub process_request {
85          $sock->blocking( 1 );          $sock->blocking( 1 );
86    
87          ### read the first line of response          ### read the first line of response
88          my $line = $sock->getline || $self->error(400, "No Data");          my $line = $sock->getline || return $self->error(400, "No Data");
89    
90          $line =~ s/[\r\n]+$//;          $line =~ s/[\r\n]+$//;
91          if ($line !~ /^ (\w+) \ + (\S+) \ + (HTTP\/1.\d) $ /x) {          if ($line !~ /^ (\w+) \ + (\S+) \ + (HTTP\/1.\d) $ /x) {
# Line 180  sub process_request { Line 188  sub process_request {
188    
189  };  };
190    
191    =head2 read_headers
192    
193    parse headers from request
194    
195    =cut
196    
197  sub read_headers {  sub read_headers {
198    my $self = shift;    my $self = shift;
# Line 197  sub read_headers { Line 210  sub read_headers {
210    return 1;    return 1;
211  }  }
212    
213    =head2 header
214    
215    Getter for specific header
216    
217      $self->header('Cookies');
218    
219    =cut
220    
221  sub header {  sub header {
222          my $self = shift;          my $self = shift;
223          my $header = shift || die "no header?";          my $header = shift || die "no header?";
# Line 207  sub header { Line 228  sub header {
228          }          }
229  }  }
230    
231    =head2 error
232    
233      return $self->error( 501, 'System error' );
234    
235    =cut
236    
237  sub error {  sub error {
238    my ($self, $number, $msg) = @_;    my ($self, $number, $msg) = @_;
239    $msg ||= 'ERROR';    $msg ||= 'ERROR';
240    $self->sock->send( "HTTP/1.1 $number $msg\r\n" );    $self->sock->send( "HTTP/1.1 $number $msg\r\n" );
241    warn "Error - $number - $msg\n";    warn "Error - $number - $msg\n";
242      return 0;     # close connection
243  }  }
244    
245  1;  1;

Legend:
Removed from v.47  
changed lines
  Added in v.48

  ViewVC Help
Powered by ViewVC 1.1.26