/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (hide annotations)
Mon Jun 18 19:16:28 2007 UTC (16 years, 11 months ago) by dpavlin
Original Path: google/lib/CWMP/Server.pm
File size: 1287 byte(s)
extracted ACS server parts into CWMP::Server
1 dpavlin 30 # Dobrica Pavlinusic, <dpavlin@rot13.org> 06/18/07 10:19:50 CEST
2     package CWMP::Server;
3    
4     use strict;
5     use warnings;
6    
7     use base qw/HTTP::Server::Simple::CGI Class::Accessor/;
8    
9     __PACKAGE__->mk_accessors( qw/
10     debug
11     / );
12    
13    
14     use Data::Dump qw/dump/;
15    
16     sub handler {
17     my $self = shift;
18    
19     my $chunk;
20    
21     my $transfer_encoding = $self->header('Transfer-Encoding');
22    
23     if ( $transfer_encoding && $transfer_encoding =~ qr/^chunked/i ) {
24    
25     my $last = 0;
26     do {
27     my $len = <STDIN>;
28     $len =~ s/[\n\r]*$//s;
29     $len = hex( $len );
30    
31     $last = 1 if ( $len == 0 );
32    
33     warn "getting chunk of $len bytes\n";
34    
35     while( $len > 0 ) {
36     my $line = <STDIN>;
37     $chunk .= $line;
38     $len -= length( $line );
39     }
40    
41     } while ( ! $last );
42     }
43    
44     warn "chunk (", length($chunk), " bytes)\n------>>\n$chunk\n<<-----\n";
45    
46     my $cgi = new CGI( $chunk );
47    
48     eval { $self->handle_request($cgi) };
49     if ($@) {
50     my $error = $@;
51     warn $error;
52     }
53     }
54    
55     sub handle_request {
56     my ($self, $cgi) = @_;
57    
58     #... do something, print output to default
59     # selected filehandle...
60    
61     warn ">> ", $ENV{REMOTE_ADDR}, $/;
62    
63     warn "not SOAP request" unless defined ( $cgi->header('SOAPAction') );
64    
65     # warn $cgi->param('POSTDATA'), dump( $cgi );
66    
67     print "Content-Type: text/xml\r\n\r\n";
68    
69     };
70    
71     1;
72    

  ViewVC Help
Powered by ViewVC 1.1.26