|
From: <jgr...@us...> - 2003-07-28 00:03:07
|
Update of /cvsroot/popfile/engine/UI
In directory sc8-pr-cvs1:/tmp/cvs-serv20181/UI
Modified Files:
HTTP.pm
Log Message:
Complete test suite for the UI::HTTP module
Index: HTTP.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/HTTP.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** HTTP.pm 26 Jul 2003 23:52:44 -0000 1.10
--- HTTP.pm 28 Jul 2003 00:03:03 -0000 1.11
***************
*** 33,36 ****
--- 33,38 ----
my $self = POPFile::Module->new();
+ bless $self;
+
return $self;
}
***************
*** 47,60 ****
my ( $self ) = @_;
! $self->{server_} = IO::Socket::INET->new( Proto => 'tcp',
$self->config_( 'local' ) == 1 ? (LocalAddr => 'localhost') : (),
LocalPort => $self->config_( 'port' ),
Listen => SOMAXCONN,
! Reuse => 1 );
if ( !defined( $self->{server_} ) ) {
my $port = $self->config_( 'port' );
my $name = $self->name();
! print <<EOM;
\nCouldn't start the $name HTTP interface because POPFile could not bind to the
--- 49,62 ----
my ( $self ) = @_;
! $self->{server_} = IO::Socket::INET->new( Proto => 'tcp', # PROFILE BLOCK START
$self->config_( 'local' ) == 1 ? (LocalAddr => 'localhost') : (),
LocalPort => $self->config_( 'port' ),
Listen => SOMAXCONN,
! Reuse => 1 ); # PROFILE BLOCK STOP
if ( !defined( $self->{server_} ) ) {
my $port = $self->config_( 'port' );
my $name = $self->name();
! print STDERR <<EOM; # PROFILE BLOCK START
\nCouldn't start the $name HTTP interface because POPFile could not bind to the
***************
*** 65,68 ****
--- 67,71 ----
EOM
+ # PROFILE BLOCK STOP
return 0;
***************
*** 115,120 ****
my ( $remote_port, $remote_host ) = sockaddr_in( $client->peername() );
! if ( ( $self->config_( 'local' ) == 0 ) ||
! ( $remote_host eq inet_aton( "127.0.0.1" ) ) ) {
# Read the request line (GET or POST) from the client and if we manage to do that
--- 118,123 ----
my ( $remote_port, $remote_host ) = sockaddr_in( $client->peername() );
! if ( ( $self->config_( 'local' ) == 0 ) || # PROFILE BLOCK START
! ( $remote_host eq inet_aton( "127.0.0.1" ) ) ) { # PROFILE BLOCK STOP
# Read the request line (GET or POST) from the client and if we manage to do that
***************
*** 199,203 ****
# parse_form_ - parse form data and fill in $self->{form_}
#
! # $arguments The text of the form arguments (e.g. foo=bar&baz=fou)
#
# ---------------------------------------------------------------------------------------------
--- 202,207 ----
# parse_form_ - parse form data and fill in $self->{form_}
#
! # $arguments The text of the form arguments (e.g. foo=bar&baz=fou) or separated by
! # CR/LF
#
# ---------------------------------------------------------------------------------------------
***************
*** 220,227 ****
my $need_array = defined( $self->{form_}{$arg} );
$self->{form_}{$arg} = $2;
$self->{form_}{$arg} =~ s/\+/ /g;
! # Expand %7E (hex) escapes in the form data
$self->{form_}{$arg} =~ s/%([0-9A-F][0-9A-F])/chr hex $1/gie;
--- 224,237 ----
my $need_array = defined( $self->{form_}{$arg} );
+ if ( $need_array ) {
+ if ( $#{ $self->{form_}{$arg . "_array"} } == -1 ) {
+ push( @{ $self->{form_}{$arg . "_array"} }, $self->{form_}{$arg} );
+ }
+ }
+
$self->{form_}{$arg} = $2;
$self->{form_}{$arg} =~ s/\+/ /g;
! # Expand hex escapes in the form data
$self->{form_}{$arg} =~ s/%([0-9A-F][0-9A-F])/chr hex $1/gie;
***************
*** 249,253 ****
$text =~ s/ /\+/;
! $text =~ s/([^a-zA-Z0-9_\-.+])/sprintf("%%%02x",ord($1))/eg;
return $text;
--- 259,263 ----
$text =~ s/ /\+/;
! $text =~ s/([^a-zA-Z0-9_\-.\+\'!~*\(\)])/sprintf("%%%02x",ord($1))/eg;
return $text;
***************
*** 268,272 ****
my ( $self, $client, $url ) = @_;
! my $header = "HTTP/1.0 302 Found\r\nLocation: ";
$header .= $url;
$header .= "$eol$eol";
--- 278,282 ----
my ( $self, $client, $url ) = @_;
! my $header = "HTTP/1.0 302 Found$eol" . 'Location: ';
$header .= $url;
$header .= "$eol$eol";
***************
*** 326,334 ****
my ( $sec, $min, $hour, $mday, $mon, $year, $wday ) = gmtime( $zulu );
! my $expires = sprintf( "%s, %02d %s %04d %02d:%02d:%02d GMT",
$day[$wday], $mday, $month[$mon], $year+1900,
! $hour, $min, $sec);
! my $header = "HTTP/1.0 200 OK\r\nContent-Type: $type\r\nExpires: $expires\r\nContent-Length: ";
$header .= length($contents);
$header .= "$eol$eol";
--- 336,344 ----
my ( $sec, $min, $hour, $mday, $mon, $year, $wday ) = gmtime( $zulu );
! my $expires = sprintf( "%s, %02d %s %04d %02d:%02d:%02d GMT", # PROFILE BLOCK START
$day[$wday], $mday, $month[$mon], $year+1900,
! $hour, 59, 0); # PROFILE BLOCK STOP
! my $header = "HTTP/1.0 200 OK$eol" . "Content-Type: $type$eol" . "Expires: $expires$eol" . "Content-Length: ";
$header .= length($contents);
$header .= "$eol$eol";
|