/[cwmp]/google/lib/CWMP/Server.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

Contents of /google/lib/CWMP/Server.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations)
Mon Jun 18 20:07:17 2007 UTC (16 years, 11 months ago) by dpavlin
File size: 1222 byte(s)
a huge chunk of changes implementing skeleton for request and response as
well as some tests
1 # 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 $len = 0;
26 do {
27 $len = <STDIN>;
28 $len =~ s/[\n\r]*$//s;
29 $len = hex( $len );
30
31 #warn "getting chunk of $len bytes\n";
32
33 while( $len > 0 ) {
34 my $line = <STDIN>;
35 $chunk .= $line;
36 $len -= length( $line );
37 }
38
39 } while ( $len > 0 );
40 }
41
42 warn "got ", length($chunk), " bytes\n";
43
44 my $cgi = new CGI( $chunk );
45
46 eval { $self->handle_request($cgi) };
47 if ($@) {
48 my $error = $@;
49 warn $error;
50 }
51 }
52
53 sub handle_request {
54 my ($self, $cgi) = @_;
55
56 #... do something, print output to default
57 # selected filehandle...
58
59 warn ">> ", $ENV{REMOTE_ADDR}, $/;
60
61 warn "not SOAP request" unless defined ( $cgi->header('SOAPAction') );
62
63 # warn $cgi->param('POSTDATA'), dump( $cgi );
64
65 print "Content-Type: text/xml\r\n\r\n";
66
67 };
68
69 1;
70

  ViewVC Help
Powered by ViewVC 1.1.26