r2420 - in packages: . libhttp-server-simple-perl libhttp-server-simple-perl/branches libhttp-server-simple-perl/branches/upstream libhttp-server-simple-perl/branches/upstream/current libhttp-server-simple-perl/branches/upstream/current/ex libhttp-server-simple-perl/branches/upstream/current/inc libhttp-server-simple-perl/branches/upstream/current/inc/Module libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install libhttp-server-simple-perl/branches/upstream/current/lib libhttp-server-simple-perl/branches/upstream/current/lib/HTTP libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/CGI libhttp-server-simple-perl/branches/upstream/current/t

Niko Tyni ntyni-guest at costa.debian.org
Fri Mar 17 22:38:00 UTC 2006


Author: ntyni-guest
Date: 2006-03-17 22:36:34 +0000 (Fri, 17 Mar 2006)
New Revision: 2420

Added:
   packages/libhttp-server-simple-perl/
   packages/libhttp-server-simple-perl/branches/
   packages/libhttp-server-simple-perl/branches/upstream/
   packages/libhttp-server-simple-perl/branches/upstream/current/
   packages/libhttp-server-simple-perl/branches/upstream/current/Changes
   packages/libhttp-server-simple-perl/branches/upstream/current/MANIFEST
   packages/libhttp-server-simple-perl/branches/upstream/current/META.yml
   packages/libhttp-server-simple-perl/branches/upstream/current/Makefile.PL
   packages/libhttp-server-simple-perl/branches/upstream/current/README
   packages/libhttp-server-simple-perl/branches/upstream/current/SIGNATURE
   packages/libhttp-server-simple-perl/branches/upstream/current/ex/
   packages/libhttp-server-simple-perl/branches/upstream/current/ex/sample_server
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Base.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Can.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Fetch.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Makefile.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Metadata.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Win32.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/WriteAll.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/lib/
   packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/
   packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/
   packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/
   packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/CGI.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/CGI/
   packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/CGI/Environment.pm
   packages/libhttp-server-simple-perl/branches/upstream/current/t/
   packages/libhttp-server-simple-perl/branches/upstream/current/t/00smoke.t
   packages/libhttp-server-simple-perl/branches/upstream/current/t/01live.t
   packages/libhttp-server-simple-perl/branches/upstream/current/t/02pod.t
   packages/libhttp-server-simple-perl/branches/upstream/current/t/03podcoverage.t
   packages/libhttp-server-simple-perl/branches/upstream/current/t/04cgi.t
   packages/libhttp-server-simple-perl/tags/
Log:
[svn-inject] Installing original source of libhttp-server-simple-perl

Added: packages/libhttp-server-simple-perl/branches/upstream/current/Changes
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/Changes	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/Changes	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,81 @@
+0.16 Mon Nov  7 14:40:43 EST 2005
+
+  SIG{'HUP'} does not exist on Win32 (cpan #15606)
+
+0.15 Thu Oct  6 21:11:02 EDT 2005
+
+  Precompute the local host's hostname and IP to save on DNS lookups at runtime 
+
+0.14 Thu Oct  6 20:48:49 EDT 2005
+
+  Split out HTTP::Server::Simple::CGI::Environment to support non-CGI.pm CGIs
+  Ignore SIGPIPE
+  
+  Signal handlers are now installed on ->run, not on new. Also, they're 
+  documented. Thanks to Mark Fowler.
+ 
+  We no longer lookup $ENV{'REMOTE_HOST'} by hostname, as it can cause huge performance problems.
+
+0.13 Tue Aug  9 21:25:20 EDT 2005
+
+  Signal handlers should be 'localed', so as not to mess with others' 
+  code. -- Thanks to David Wheeler
+
+0.12 Sun Jul 17 02:14:57 EDT 2005
+
+  Test suite improvements from Mattia Barbon
+
+0.11 Fri Jul  8 22:56:01 EDT 2005
+  Bogus META.yml broke signature checks. Thanks to sungo.
+
+0.10 Tue Jun 28 11:27:58 EDT 2005
+
+- Allow separate treatment of STDIN and STDOUT handles to the server.  This
+  gives support for HTTP::Server::Simple::Recorder.
+
+0.09 Tue Apr 19 21:43:31 EDT 2005
+
+- Now we set the GATEWAY_INTERFACE metavariable in H:S:S:CGI.
+
+0.08 Sat Apr 16 01:27:17 EDT 2005
+
+- New tests for HTTP::Server:Simple::CGI from hide.
+
+0.07 Sat Mar 26 14:25:38 CST 2005
+
+- PAUSE broke :/
+
+0.05 Sat Mar 26 14:14:54 CST 2005
+
+- Fix a bug in HTTP::Server::Simple::CGI that clobbered CGI ENV variables
+  in some cases. Thanks, Hide.
+- New public subclass-overridable method ->net_server() that can
+  optionally take a Net::Server subclass name and use it to replace
+  the default ->run() method. -- Autrijus Tang
+
+0.04 Tue Mar 22 23:34:36 CST 2005
+- Changed ->headers calling conventions. This may break backwards compat,
+  but is cleaner and safer.
+- Fixed bugs in ::CGI that broke http header handling
+- Refactored code to be more transparent
+- Patch from Sebastian Riedel to do proper parsing of form data from STDIN
+
+0.03_03 Fri Mar 18 15:09:52 EST 2005
+- Finish fixes from http://rt.cpan.org/NoAuth/Bug.html?id=11409
+
+
+0.03_02 Thu Feb 17 23:34:00 NZDT 2005
+- Make test script not depend on LWP
+- Add ->header(), and various generic hook capabilities
+- Made HTTP::Server::Simple::CGI use those hooks
+- Add ->bad_request(), for protocol errors
+
+0.03_01 Thu Feb 17 21:39:34 NZDT 2005
+- Add ->setup() and ->handler()
+- Add support for specifying a host to bind listener to
+- Split out CGI.pm support into sub-class
+- Add Changes file to MANIFEST
+
+0.03 Wed Jan 26 08:55:34 EST 2005
+
+- Test fixes for Win32

Added: packages/libhttp-server-simple-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/MANIFEST	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/MANIFEST	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,23 @@
+ex/sample_server
+inc/Module/Install.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+lib/HTTP/Server/Simple.pm
+lib/HTTP/Server/Simple/CGI.pm
+lib/HTTP/Server/Simple/CGI/Environment.pm
+Makefile.PL
+MANIFEST			This list of files
+META.yml
+README
+Changes
+SIGNATURE
+t/00smoke.t
+t/01live.t
+t/02pod.t
+t/03podcoverage.t
+t/04cgi.t

Added: packages/libhttp-server-simple-perl/branches/upstream/current/META.yml
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/META.yml	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/META.yml	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,12 @@
+name: HTTP-Server-Simple
+version: 0.16
+license: perl
+distribution_type: module
+requires:
+  Socket: 0
+  Test::More: 0
+  CGI: 0
+no_index:
+  directory:
+    - inc
+generated_by: Module::Install version 0.37

Added: packages/libhttp-server-simple-perl/branches/upstream/current/Makefile.PL
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/Makefile.PL	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/Makefile.PL	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,11 @@
+use inc::Module::Install;
+
+version_from('lib/HTTP/Server/Simple.pm');
+name('HTTP-Server-Simple');
+license('perl');
+requires ( Socket => 0,
+	   Test::More => 0,
+	   CGI => 0);
+
+   &WriteAll;
+

Added: packages/libhttp-server-simple-perl/branches/upstream/current/README
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/README	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/README	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,13 @@
+HTTP::Server::Simple is a very simple standalone HTTP daemon with no non-core
+module dependencies.  It's ideal for building a standalone http-based UI to
+your existing tools.  
+
+This code is a derivative of the "standalone_httpd" tool used by RT.
+(http://bestpractical.com/rt)
+
+It's desperately short of tests and documentation. It wants your love and help.
+
+
+
+    Jesse Vincent
+    jesse at bestpractical.com. 

Added: packages/libhttp-server-simple-perl/branches/upstream/current/SIGNATURE
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/SIGNATURE	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/SIGNATURE	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,45 @@
+This file contains message digests of all files listed in MANIFEST,
+signed via the Module::Signature module, version 0.50.
+
+To verify the content in this distribution, first make sure you have
+Module::Signature installed, then type:
+
+    % cpansign -v
+
+It will check each file's integrity, as well as the signature's
+validity.  If "==> Signature verified OK! <==" is not displayed,
+the distribution may already have been compromised, and you should
+not run its Makefile.PL or Build.PL.
+
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+SHA1 26bb64f3864e5f6784401a38e226aa1ddd73edde Changes
+SHA1 0ac508c50476dcc2bf8fe3094cb341425291e1ee MANIFEST
+SHA1 ecbd933c6b8e7d47e41fc16c3f21c8df92fa2c3f META.yml
+SHA1 490f3fd115e09cb05b725580e5ed5cdd58241049 Makefile.PL
+SHA1 ed0c107672daac3bc9e266876666e1059dbe44b7 README
+SHA1 4ea1e9072ca87399184a46233df52a21e285604d ex/sample_server
+SHA1 842ab7e28834effb9e4222aab72c4106727dea0f inc/Module/Install.pm
+SHA1 1da4fc271065900f73682f31d4f9c0dae5288143 inc/Module/Install/Base.pm
+SHA1 0d0b6772bd5ec750e99d238942c88329e394d48d inc/Module/Install/Can.pm
+SHA1 a784ba7d2b096084b2ffed3a7d853e2847f4dedb inc/Module/Install/Fetch.pm
+SHA1 dc2af04175831ddb9a00de944e761e5c46bbf283 inc/Module/Install/Makefile.pm
+SHA1 421da5922ad85b72ae5b27c33803e86b3762d238 inc/Module/Install/Metadata.pm
+SHA1 2a1b494a7e5adaa3216e86d909dd5bf87d084c80 inc/Module/Install/Win32.pm
+SHA1 c92e1d32922615347e059e7e3a2f53b5e9c98e3b inc/Module/Install/WriteAll.pm
+SHA1 f6b00458452368320b19750392487cf1e8515c1b lib/HTTP/Server/Simple.pm
+SHA1 2d7348b166f654a460ddae4cb4183f4a544c85fc lib/HTTP/Server/Simple/CGI.pm
+SHA1 b2c2d007a7f50058c874e633d15fb621b2bfc394 lib/HTTP/Server/Simple/CGI/Environment.pm
+SHA1 db064af54cab345a71daec576e32e64b8fb1033d t/00smoke.t
+SHA1 9e68bffc26b5a42e2785ec68c3bf6fe45d6bb6da t/01live.t
+SHA1 aca95653cfce68912e08c57b3a4566207e2f99b3 t/02pod.t
+SHA1 90f0be3e6b0fab021155953742f5cc5c5e47a5aa t/03podcoverage.t
+SHA1 0ca7d32c396129b38a33a8077171b84076feb8d9 t/04cgi.t
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.1 (GNU/Linux)
+
+iD8DBQFDb63XEi9d9xCOQEYRArQVAJ44Bkj2jqybBIr71mclQ0aOi/u2cgCgkakh
+e210lVUgdouYs0xX1F+CElo=
+=odXJ
+-----END PGP SIGNATURE-----

Added: packages/libhttp-server-simple-perl/branches/upstream/current/ex/sample_server
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/ex/sample_server	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/ex/sample_server	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,9 @@
+#!perl
+
+use warnings;
+use strict;
+
+use HTTP::Server::Simple::CGI;
+
+my $server = HTTP::Server::Simple->new();
+$server->run();

Added: packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Base.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Base.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Base.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,54 @@
+#line 1 "inc/Module/Install/Base.pm - /usr/local/share/perl/5.8.7/Module/Install/Base.pm"
+package Module::Install::Base;
+
+#line 28
+
+sub new {
+    my ($class, %args) = @_;
+
+    foreach my $method (qw(call load)) {
+        *{"$class\::$method"} = sub {
+            +shift->_top->$method(@_);
+        } unless defined &{"$class\::$method"};
+    }
+
+    bless(\%args, $class);
+}
+
+#line 46
+
+sub AUTOLOAD {
+    my $self = shift;
+    goto &{$self->_top->autoload};
+}
+
+#line 57
+
+sub _top { $_[0]->{_top} }
+
+#line 68
+
+sub admin {
+    my $self = shift;
+    $self->_top->{admin} or Module::Install::Base::FakeAdmin->new;
+}
+
+sub is_admin {
+    my $self = shift;
+    $self->admin->VERSION;
+}
+
+sub DESTROY {}
+
+package Module::Install::Base::FakeAdmin;
+
+my $Fake;
+sub new { $Fake ||= bless(\@_, $_[0]) }
+sub AUTOLOAD {}
+sub DESTROY {}
+
+1;
+
+__END__
+
+#line 112

Added: packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Can.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Can.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Can.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,38 @@
+#line 1 "inc/Module/Install/Can.pm - /usr/local/share/perl/5.8.7/Module/Install/Can.pm"
+package Module::Install::Can;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+$VERSION = '0.01';
+
+use strict;
+use Config ();
+use File::Spec ();
+use ExtUtils::MakeMaker ();
+
+# check if we can run some command
+sub can_run {
+    my ($self, $cmd) = @_;
+
+    my $_cmd = $cmd;
+    return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
+
+    for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
+        my $abs = File::Spec->catfile($dir, $_[1]);
+        return $abs if (-x $abs or $abs = MM->maybe_command($abs));
+    }
+
+    return;
+}
+
+sub can_cc {
+    my $self = shift;
+    my @chunks = split(/ /, $Config::Config{cc}) or return;
+
+    # $Config{cc} may contain args; try to find out the program part
+    while (@chunks) {
+        return $self->can_run("@chunks") || (pop(@chunks), next);
+    }
+
+    return;
+}
+
+1;

Added: packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Fetch.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Fetch.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Fetch.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,86 @@
+#line 1 "inc/Module/Install/Fetch.pm - /usr/local/share/perl/5.8.7/Module/Install/Fetch.pm"
+package Module::Install::Fetch;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.01';
+
+sub get_file {
+    my ($self, %args) = @_;
+    my ($scheme, $host, $path, $file) = 
+        $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
+
+    if ($scheme eq 'http' and !eval { require LWP::Simple; 1 }) {
+        $args{url} = $args{ftp_url}
+            or (warn("LWP support unavailable!\n"), return);
+        ($scheme, $host, $path, $file) = 
+            $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
+    }
+
+    $|++;
+    print "Fetching '$file' from $host... ";
+
+    unless (eval { require Socket; Socket::inet_aton($host) }) {
+        warn "'$host' resolve failed!\n";
+        return;
+    }
+
+    return unless $scheme eq 'ftp' or $scheme eq 'http';
+
+    require Cwd;
+    my $dir = Cwd::getcwd();
+    chdir $args{local_dir} or return if exists $args{local_dir};
+
+    if (eval { require LWP::Simple; 1 }) {
+        LWP::Simple::mirror($args{url}, $file);
+    }
+    elsif (eval { require Net::FTP; 1 }) { eval {
+        # use Net::FTP to get past firewall
+        my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600);
+        $ftp->login("anonymous", 'anonymous at example.com');
+        $ftp->cwd($path);
+        $ftp->binary;
+        $ftp->get($file) or (warn("$!\n"), return);
+        $ftp->quit;
+    } }
+    elsif (my $ftp = $self->can_run('ftp')) { eval {
+        # no Net::FTP, fallback to ftp.exe
+        require FileHandle;
+        my $fh = FileHandle->new;
+
+        local $SIG{CHLD} = 'IGNORE';
+        unless ($fh->open("|$ftp -n")) {
+            warn "Couldn't open ftp: $!\n";
+            chdir $dir; return;
+        }
+
+        my @dialog = split(/\n/, << ".");
+open $host
+user anonymous anonymous\@example.com
+cd $path
+binary
+get $file $file
+quit
+.
+        foreach (@dialog) { $fh->print("$_\n") }
+        $fh->close;
+    } }
+    else {
+        warn "No working 'ftp' program available!\n";
+        chdir $dir; return;
+    }
+
+    unless (-f $file) {
+        warn "Fetching failed: $@\n";
+        chdir $dir; return;
+    }
+
+    return if exists $args{size} and -s $file != $args{size};
+    system($args{run}) if exists $args{run};
+    unlink($file) if $args{remove};
+
+    print(((!exists $args{check_for} or -e $args{check_for})
+        ? "done!" : "failed! ($!)"), "\n");
+    chdir $dir; return !$?;
+}
+
+1;

Added: packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Makefile.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Makefile.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Makefile.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,144 @@
+#line 1 "inc/Module/Install/Makefile.pm - /usr/local/share/perl/5.8.7/Module/Install/Makefile.pm"
+package Module::Install::Makefile;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.01';
+
+use strict 'vars';
+use vars '$VERSION';
+
+use ExtUtils::MakeMaker ();
+
+sub Makefile { $_[0] }
+
+sub prompt { 
+    shift;
+    goto &ExtUtils::MakeMaker::prompt;
+}
+
+sub makemaker_args {
+    my $self = shift;
+    my $args = ($self->{makemaker_args} ||= {});
+    %$args = ( %$args, @_ ) if @_;
+    $args;
+}
+
+sub clean_files {
+    my $self = shift;
+    my $clean = $self->makemaker_args->{clean} ||= {};
+    %$clean = (
+        %$clean, 
+        FILES => join(" ", grep length, $clean->{FILES}, @_),
+    );
+}
+
+sub libs {
+    my $self = shift;
+    my $libs = ref $_[0] ? shift : [shift];
+    $self->makemaker_args( LIBS => $libs );
+}
+
+sub inc {
+    my $self = shift;
+    $self->makemaker_args( INC => shift );
+}
+
+sub write {
+    my $self = shift;
+    die "&Makefile->write() takes no arguments\n" if @_;
+
+    my $args = $self->makemaker_args;
+
+    $args->{DISTNAME} = $self->name;
+    $args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args);
+    $args->{VERSION} = $self->version || $self->determine_VERSION($args);
+    $args->{NAME} =~ s/-/::/g;
+    $args->{test} = {TESTS => $self->tests};
+
+    if ($] >= 5.005) {
+	$args->{ABSTRACT} = $self->abstract;
+	$args->{AUTHOR} = $self->author;
+    }
+    if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) {
+        $args->{NO_META} = 1;
+    }
+    if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 ) {
+	$args->{SIGN} = 1 if $self->sign;
+    }
+    delete $args->{SIGN} unless $self->is_admin;
+
+    # merge both kinds of requires into prereq_pm
+    my $prereq = ($args->{PREREQ_PM} ||= {});
+    %$prereq = ( %$prereq, map { @$_ } map { @$_ } grep $_,
+                 ($self->build_requires, $self->requires) );
+
+    # merge both kinds of requires into prereq_pm
+    my $dir = ($args->{DIR} ||= []);
+    if ($self->bundles) {
+        push @$dir, map "$_->[1]", @{$self->bundles};
+        delete $prereq->{$_->[0]} for @{$self->bundles};
+    }
+
+    if (my $perl_version = $self->perl_version) {
+        eval "use $perl_version; 1"
+            or die "ERROR: perl: Version $] is installed, ".
+                   "but we need version >= $perl_version";
+    }
+
+    my %args = map {($_ => $args->{$_})} grep {defined($args->{$_})} keys %$args;
+
+    if ($self->admin->preop) {
+        $args{dist} = $self->admin->preop;
+    }
+
+    ExtUtils::MakeMaker::WriteMakefile(%args);
+
+    $self->fix_up_makefile();
+}
+
+sub fix_up_makefile {
+    my $self = shift;
+    my $top_class = ref($self->_top) || '';
+    my $top_version = $self->_top->VERSION || '';
+
+    my $preamble = $self->preamble 
+       ? "# Preamble by $top_class $top_version\n" . $self->preamble
+       : '';
+    my $postamble = "# Postamble by $top_class $top_version\n" . 
+                    ($self->postamble || '');
+
+    open MAKEFILE, '< Makefile' or die $!;
+    my $makefile = do { local $/; <MAKEFILE> };
+    close MAKEFILE;
+
+    $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
+    $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
+    $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g;
+
+    $makefile =~ s/^(FULLPERL = .*)/$1 -Iinc/m;
+    $makefile =~ s/^(PERL = .*)/$1 -Iinc/m;
+
+    open MAKEFILE, '> Makefile' or die $!;
+    print MAKEFILE "$preamble$makefile$postamble";
+    close MAKEFILE;
+}
+
+sub preamble {
+    my ($self, $text) = @_;
+    $self->{preamble} = $text . $self->{preamble} if defined $text;
+    $self->{preamble};
+}
+
+sub postamble {
+    my ($self, $text) = @_;
+
+    $self->{postamble} ||= $self->admin->postamble;
+    $self->{postamble} .= $text if defined $text;
+    $self->{postamble}
+}
+
+1;
+
+__END__
+
+#line 274

Added: packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Metadata.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Metadata.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Metadata.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,187 @@
+#line 1 "inc/Module/Install/Metadata.pm - /usr/local/share/perl/5.8.7/Module/Install/Metadata.pm"
+package Module::Install::Metadata;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.04';
+
+use strict 'vars';
+use vars qw($VERSION);
+
+sub Meta { shift }
+
+my @scalar_keys = qw(
+    name module_name version abstract author license
+    distribution_type sign perl_version tests
+);
+my @tuple_keys  = qw(build_requires requires recommends bundles);
+
+foreach my $key (@scalar_keys) {
+    *$key = sub {
+        my $self = shift;
+        return $self->{'values'}{$key} unless @_;
+        $self->{'values'}{$key} = shift;
+        return $self;
+    };
+}
+
+foreach my $key (@tuple_keys) {
+    *$key = sub {
+        my $self = shift;
+        return $self->{'values'}{$key} unless @_;
+        my @rv;
+        while (@_) {
+            my $module  = shift or last;
+            my $version = shift || 0;
+            if ($module eq 'perl') {
+                $version =~ s{^(\d+)\.(\d+)\.(\d+)}
+                             {$1 + $2/1_000 + $3/1_000_000}e;
+                $self->perl_version($version);
+                next;
+            }
+            my $rv = [$module, $version];
+            push @{$self->{'values'}{$key}}, $rv;
+            push @rv, $rv;
+        }
+        return @rv;
+    };
+}
+
+sub features {
+    my $self = shift;
+    while (my ($name, $mods) = splice(@_, 0, 2)) {
+        my $count = 0;
+        push @{$self->{'values'}{'features'}}, ($name => [
+            map { (++$count % 2 and ref($_) and ($count += $#$_)) ? @$_ : $_ } @$mods
+        ] );
+    }
+    return @{$self->{'values'}{'features'}};
+}
+
+sub no_index {
+    my $self = shift;
+    my $type = shift;
+    push @{$self->{'values'}{'no_index'}{$type}}, @_ if $type;
+    return $self->{'values'}{'no_index'};
+}
+
+sub _dump {
+    my $self = shift;
+    my $package = ref($self->_top);
+    my $version = $self->_top->VERSION;
+    my %values = %{$self->{'values'}};
+
+    delete $values{sign};
+    if (my $perl_version = delete $values{perl_version}) {
+        # Always canonical to three-dot version 
+        $perl_version =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2), int($3))}e
+            if $perl_version >= 5.006;
+        $values{requires} = [
+            [perl => $perl_version],
+            @{$values{requires}||[]},
+        ];
+    }
+
+    warn "No license specified, setting license = 'unknown'\n"
+        unless $values{license};
+
+    $values{license} ||= 'unknown';
+    $values{distribution_type} ||= 'module';
+    $values{name} ||= do {
+        my $name = $values{module_name};
+        $name =~ s/::/-/g;
+        $name;
+    } if $values{module_name};
+
+    if ($values{name} =~ /::/) {
+        my $name = $values{name};
+        $name =~ s/::/-/g;
+        die "Error in name(): '$values{name}' should be '$name'!\n";
+    }
+
+    my $dump = '';
+    foreach my $key (@scalar_keys) {
+        $dump .= "$key: $values{$key}\n" if exists $values{$key};
+    }
+    foreach my $key (@tuple_keys) {
+        next unless exists $values{$key};
+        $dump .= "$key:\n";
+        foreach (@{$values{$key}}) {
+            $dump .= "  $_->[0]: $_->[1]\n";
+        }
+    }
+
+    if (my $no_index = $values{no_index}) {
+        push @{$no_index->{'directory'}}, 'inc';
+        require YAML;
+        local $YAML::UseHeader = 0;
+        $dump .= YAML::Dump({ no_index => $no_index});
+    }
+    else {
+        $dump .= << "META";
+no_index:
+  directory:
+    - inc
+META
+    }
+    
+    $dump .= "generated_by: $package version $version\n";
+    return $dump;
+}
+
+sub read {
+    my $self = shift;
+    $self->include_deps( 'YAML', 0 );
+    require YAML;
+    my $data = YAML::LoadFile( 'META.yml' );
+    # Call methods explicitly in case user has already set some values.
+    while ( my ($key, $value) = each %$data ) {
+        next unless $self->can( $key );
+        if (ref $value eq 'HASH') {
+            while (my ($module, $version) = each %$value) {
+                $self->$key( $module => $version );
+            }
+        }
+        else {
+            $self->$key( $value );
+        }
+    }
+    return $self;
+}
+
+sub write {
+    my $self = shift;
+    return $self unless $self->is_admin;
+
+    META_NOT_OURS: {
+        local *FH;
+        if (open FH, "META.yml") {
+            while (<FH>) {
+                last META_NOT_OURS if /^generated_by: Module::Install\b/;
+            }
+            return $self if -s FH;
+        }
+    }
+
+    warn "Writing META.yml\n";
+    open META, "> META.yml" or warn "Cannot write to META.yml: $!";
+    print META $self->_dump;
+    close META;
+    return $self;
+}
+
+sub version_from {
+    my ($self, $version_from) = @_;
+    require ExtUtils::MM_Unix;
+    $self->version(ExtUtils::MM_Unix->parse_version($version_from));
+}
+
+sub abstract_from {
+    my ($self, $abstract_from) = @_;
+    require ExtUtils::MM_Unix;
+    $self->abstract(
+        bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix')
+            ->parse_abstract($abstract_from)
+    );
+}
+
+1;

Added: packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Win32.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Win32.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/Win32.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,63 @@
+#line 1 "inc/Module/Install/Win32.pm - /usr/local/share/perl/5.8.7/Module/Install/Win32.pm"
+package Module::Install::Win32;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.02';
+
+use strict;
+
+# determine if the user needs nmake, and download it if needed
+sub check_nmake {
+    my $self = shift;
+    $self->load('can_run');
+    $self->load('get_file');
+
+    require Config;
+    return unless (
+        $Config::Config{make}                   and
+        $Config::Config{make} =~ /^nmake\b/i    and
+        $^O eq 'MSWin32'                        and
+        !$self->can_run('nmake')
+    );
+
+    print "The required 'nmake' executable not found, fetching it...\n";
+
+    require File::Basename;
+    my $rv = $self->get_file(
+        url         => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe',
+        ftp_url     => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe',
+        local_dir   => File::Basename::dirname($^X),
+        size        => 51928,
+        run         => 'Nmake15.exe /o > nul',
+        check_for   => 'Nmake.exe',
+        remove      => 1,
+    );
+
+    if (!$rv) {
+        die << '.';
+
+-------------------------------------------------------------------------------
+
+Since you are using Microsoft Windows, you will need the 'nmake' utility
+before installation. It's available at:
+
+  http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
+      or
+  ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe
+
+Please download the file manually, save it to a directory in %PATH% (e.g.
+C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to
+that directory, and run "Nmake15.exe" from there; that will create the
+'nmake.exe' file needed by this module.
+
+You may then resume the installation process described in README.
+
+-------------------------------------------------------------------------------
+.
+    }
+}
+
+1;
+
+__END__
+

Added: packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/WriteAll.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/WriteAll.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install/WriteAll.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,36 @@
+#line 1 "inc/Module/Install/WriteAll.pm - /usr/local/share/perl/5.8.7/Module/Install/WriteAll.pm"
+package Module::Install::WriteAll;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+sub WriteAll {
+    my $self = shift;
+    my %args = (
+        meta => 1,
+        sign => 0,
+        inline => 0,
+        check_nmake => 1,
+        @_
+    );
+
+    $self->sign(1) if $args{sign};
+    $self->Meta->write if $args{meta};
+    $self->admin->WriteAll(%args) if $self->is_admin;
+
+    if ($0 =~ /Build.PL$/i) {
+	$self->Build->write;
+    }
+    else {
+	$self->check_nmake if $args{check_nmake};
+        $self->makemaker_args( PL_FILES => {} )
+            unless $self->makemaker_args->{'PL_FILES'};
+
+        if ($args{inline}) {
+            $self->Inline->write;
+        }
+        else {
+            $self->Makefile->write;
+        }
+    }
+}
+
+1;

Added: packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/inc/Module/Install.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,169 @@
+#line 1 "inc/Module/Install.pm - /usr/local/share/perl/5.8.7/Module/Install.pm"
+package Module::Install;
+$VERSION = '0.37';
+
+die << "." unless $INC{join('/', inc => split(/::/, __PACKAGE__)).'.pm'};
+Please invoke ${\__PACKAGE__} with:
+
+    use inc::${\__PACKAGE__};
+
+not:
+
+    use ${\__PACKAGE__};
+
+.
+
+use strict 'vars';
+use Cwd ();
+use File::Find ();
+use File::Path ();
+
+ at inc::Module::Install::ISA = 'Module::Install';
+*inc::Module::Install::VERSION = *VERSION;
+
+#line 130
+
+sub import {
+    my $class = shift;
+    my $self = $class->new(@_);
+
+    if (not -f $self->{file}) {
+        require "$self->{path}/$self->{dispatch}.pm";
+        File::Path::mkpath("$self->{prefix}/$self->{author}");
+        $self->{admin} = 
+          "$self->{name}::$self->{dispatch}"->new(_top => $self);
+        $self->{admin}->init;
+        @_ = ($class, _self => $self);
+        goto &{"$self->{name}::import"};
+    }
+
+    *{caller(0) . "::AUTOLOAD"} = $self->autoload;
+
+    # Unregister loader and worker packages so subdirs can use them again
+    delete $INC{"$self->{file}"};
+    delete $INC{"$self->{path}.pm"};
+}
+
+#line 157
+
+sub autoload {
+    my $self = shift;
+    my $caller = caller;
+
+    my $cwd = Cwd::cwd();
+    my $sym = "$caller\::AUTOLOAD";
+
+    $sym->{$cwd} = sub {
+        my $pwd = Cwd::cwd();
+        if (my $code = $sym->{$pwd}) {
+            goto &$code unless $cwd eq $pwd; # delegate back to parent dirs
+        }
+        $$sym =~ /([^:]+)$/ or die "Cannot autoload $caller";
+        unshift @_, ($self, $1);
+        goto &{$self->can('call')} unless uc($1) eq $1;
+    };
+}
+
+#line 182
+
+sub new {
+    my ($class, %args) = @_;
+
+    return $args{_self} if $args{_self};
+
+    $args{dispatch} ||= 'Admin';
+    $args{prefix}   ||= 'inc';
+    $args{author}   ||= '.author';
+    $args{bundle}   ||= 'inc/BUNDLES';
+
+    $class =~ s/^\Q$args{prefix}\E:://;
+    $args{name}     ||= $class;
+    $args{version}  ||= $class->VERSION;
+
+    unless ($args{path}) {
+        $args{path}  = $args{name};
+        $args{path}  =~ s!::!/!g;
+    }
+    $args{file}     ||= "$args{prefix}/$args{path}.pm";
+
+    bless(\%args, $class);
+}
+
+#line 211
+
+sub call {
+    my $self   = shift;
+    my $method = shift;
+    my $obj = $self->load($method) or return;
+
+    unshift @_, $obj;
+    goto &{$obj->can($method)};
+}
+
+#line 226
+
+sub load {
+    my ($self, $method) = @_;
+
+    $self->load_extensions(
+        "$self->{prefix}/$self->{path}", $self
+    ) unless $self->{extensions};
+
+    foreach my $obj (@{$self->{extensions}}) {
+        return $obj if $obj->can($method);
+    }
+
+    my $admin = $self->{admin} or die << "END";
+The '$method' method does not exist in the '$self->{prefix}' path!
+Please remove the '$self->{prefix}' directory and run $0 again to load it.
+END
+
+    my $obj = $admin->load($method, 1);
+    push @{$self->{extensions}}, $obj;
+
+    $obj;
+}
+
+#line 256
+
+sub load_extensions {
+    my ($self, $path, $top_obj) = @_;
+
+    unshift @INC, $self->{prefix}
+        unless grep { $_ eq $self->{prefix} } @INC;
+
+    local @INC = ($path, @INC);
+    foreach my $rv ($self->find_extensions($path)) {
+        my ($file, $pkg) = @{$rv};
+        next if $self->{pathnames}{$pkg};
+
+        eval { require $file; 1 } or (warn($@), next);
+        $self->{pathnames}{$pkg} = delete $INC{$file};
+        push @{$self->{extensions}}, $pkg->new( _top => $top_obj );
+    }
+}
+
+#line 280
+
+sub find_extensions {
+    my ($self, $path) = @_;
+    my @found;
+
+    File::Find::find(sub {
+        my $file = $File::Find::name;
+        return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
+        return if $1 eq $self->{dispatch};
+
+        $file = "$self->{path}/$1.pm";
+        my $pkg = "$self->{name}::$1"; $pkg =~ s!/!::!g;
+        push @found, [$file, $pkg];
+    }, $path) if -d $path;
+
+    @found;
+}
+
+1;
+
+__END__
+
+#line 618

Added: packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/CGI/Environment.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/CGI/Environment.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/CGI/Environment.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,110 @@
+
+package HTTP::Server::Simple::CGI::Environment;
+
+use strict;
+use warnings;
+
+our $VERSION = $HTTP::Server::Simple::VERSION;
+
+my %clean_env = %ENV;
+
+=head1 NAME
+
+HTTP::Server::Simple::CGI::Environment - a HTTP::Server::Simple mixin to provide the CGI protocol
+
+=head1 DESCRIPTION
+
+This mixin abstracts the CGI protocol out from HTTP::Server::Simple::CGI so that 
+it's easier to provide your own CGI handlers with HTTP::Server::Simple which 
+B<don't> use CGI.pm
+
+=head2 setup_environment
+
+C<setup_environemnt> is usually called in the superclass's accept_hook
+
+This routine in this sub-class clears the environment to the
+start-up state.
+
+=cut
+
+sub setup_environment {
+    %ENV = (
+        %clean_env,
+        SERVER_SOFTWARE   => "HTTP::Server::Simple/$VERSION",
+        GATEWAY_INTERFACE => 'CGI/1.1'
+    );
+}
+
+=head2 setup_server_url
+
+Sets up the SERVER_URL environment variable
+
+=cut
+
+sub setup_server_url {
+    $ENV{SERVER_URL}
+        ||= ( "http://" . $ENV{SERVER_NAME} . ":" . $ENV{SERVER_PORT} . "/" );
+}
+
+=head2 setup_environment_from_metadata
+
+This method sets up CGI environment variables based on various
+meta-headers, like the protocol, remote host name, request path, etc.
+
+See the docs in L<HTTP::Server::Simple> for more detail.
+
+=cut
+
+our %ENV_MAPPING = (
+    protocol     => "SERVER_PROTOCOL",
+    localport    => "SERVER_PORT",
+    localname    => "SERVER_NAME",
+    path         => "PATH_INFO",
+    request_uri  => "REQUEST_URI",
+    method       => "REQUEST_METHOD",
+    peeraddr     => "REMOTE_ADDR",
+    peername     => "REMOTE_HOST",
+    query_string => "QUERY_STRING",
+);
+
+sub setup_environment_from_metadata {
+    no warnings 'uninitialized';
+    my $self = shift;
+
+    # XXX TODO: rather than clone functionality from the base class,
+    # we should call super
+    #
+    while ( my ( $item, $value ) = splice @_, 0, 2 ) {
+        if ( my $k = $ENV_MAPPING{$item} ) {
+            $ENV{$k} = $value;
+        }
+    }
+
+}
+
+=head2  header
+
+C<header> turns a single HTTP headers into CGI environment variables.
+
+=cut
+
+sub header {
+    my $self  = shift;
+    my $tag   = shift;
+    my $value = shift;
+
+    $tag = uc($tag);
+    $tag =~ s/^COOKIES$/COOKIE/;
+    $tag =~ s/-/_/g;
+    $tag = "HTTP_" . $tag
+        unless $tag =~ m/^(?:CONTENT_(?:LENGTH|TYPE)|COOKIE)$/;
+
+    if ( exists $ENV{$tag} ) {
+        $ENV{$tag} .= "; $value";
+    }
+    else {
+        $ENV{$tag} = $value;
+    }
+}
+
+1;

Added: packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/CGI.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/CGI.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple/CGI.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,117 @@
+
+package HTTP::Server::Simple::CGI;
+
+use base qw(HTTP::Server::Simple HTTP::Server::Simple::CGI::Environment);
+use strict;
+use warnings;
+
+use CGI ();
+
+our $VERSION = $HTTP::Server::Simple::VERSION;
+
+=head1 NAME
+
+HTTP::Server::Simple::CGI - CGI.pm-style version of HTTP::Server::Simple
+
+=head1 DESCRIPTION
+
+HTTP::Server::Simple was already simple, but some smart-ass pointed
+out that there is no CGI in HTTP, and so this module was born to
+isolate the CGI.pm-related parts of this handler.
+
+
+=head2 accept_hook
+
+The accept_hook in this sub-class clears the environment to the
+start-up state.
+
+=cut
+
+sub accept_hook {
+    my $self = shift;
+    $self->setup_environment(@_);
+}
+
+=head2 post_setup_hook
+
+
+
+=cut
+
+sub post_setup_hook {
+    my $self = shift;
+    $self->setup_server_url;
+    CGI::initialize_globals();
+}
+
+=head2 setup
+
+This method sets up CGI environment variables based on various
+meta-headers, like the protocol, remote host name, request path, etc.
+
+See the docs in L<HTTP::Server::Simple> for more detail.
+
+=cut
+
+sub setup {
+    my $self = shift;
+    $self->setup_environment_from_metadata(@_);
+}
+
+=head2 handle_request CGI
+
+This routine is called whenever your server gets a request it can
+handle.
+
+It's called with a CGI object that's been pre-initialized.
+You want to override this method in your subclass
+
+
+=cut
+
+our $default_doc;
+$default_doc = ( join "", <DATA> );
+
+sub handle_request {
+    my ( $self, $cgi ) = @_;
+
+    print "HTTP/1.0 200 OK\r\n";    # probably OK by now
+    print "Content-Type: text/html\r\nContent-Length: ", length($default_doc),
+        "\r\n\r\n", $default_doc;
+}
+
+=head2 handler
+
+Handler implemented as part of HTTP::Server::Simple API
+
+=cut
+
+sub handler {
+    my $self = shift;
+    my $cgi  = new CGI();
+    eval { $self->handle_request($cgi) };
+    if ($@) {
+        my $error = $@;
+        warn $error;
+    }
+}
+
+1;
+
+__DATA__
+<html>
+  <head>
+    <title>Hello!</title>
+  </head>
+  <body>
+    <h1>Congratulations!</h1>
+
+    <p>You now have a functional HTTP::Server::Simple::CGI running.
+      </p>
+
+    <p><i>(If you're seeing this page, it means you haven't subclassed
+      HTTP::Server::Simple::CGI, which you'll need to do to make it
+      useful.)</i>
+      </p>
+  </body>
+</html>

Added: packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple.pm
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple.pm	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple.pm	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,640 @@
+package HTTP::Server::Simple;
+use 5.006;
+use strict;
+use warnings;
+use Socket;
+use Carp;
+
+our $VERSION = '0.16';
+
+=head1 NAME
+
+HTTP::Server::Simple
+
+
+=head1 SYNOPSIS
+
+ use warnings;
+ use strict;
+ 
+ use HTTP::Server::Simple;
+ 
+ my $server = HTTP::Server::Simple->new();
+ $server->run();
+
+However, normally you will sub-class the HTTP::Server::Simple::CGI
+module (see L<HTTP::Server::Simple::CGI>);
+
+ package Your::Web::Server;
+ use base qw(HTTP::Server::Simple::CGI);
+ 
+ sub handle_request {
+     my ($self, $cgi) = @_;
+
+     #... do something, print output to default
+     # selected filehandle...
+
+ }
+ 
+ 1;
+
+=head1 DESCRIPTION
+
+This is a simple standalone HTTP server. By default, it doesn't thread 
+or fork.
+
+It does, however, act as a simple frontend which can be used 
+to build a standalone web-based application or turn a CGI into one.
+
+(It's possible to use Net::Server to get threading, forking,
+preforking and so on. Autrijus Tang wrote the functionality and owes docs for that ;)
+
+By default, the server traps a few signals:
+
+=over
+
+=item HUP
+
+When you C<kill -HUP> the server, it does its best to rexec
+itself.  Please note that in order to provide restart-on-SIGHUP,
+HTTP::Server::Simple sets a SIGHUP handler during initialisation. If
+your request handling code forks you need to make sure you reset this
+or unexpected things will happen if somebody sends a HUP to all running
+processes spawned by your app (e.g. by "kill -HUP <script>")
+
+
+=item PIPE
+
+If the server detects a broken pipe while writing output to the client, 
+it ignores the signal. Otherwise, a client closing the connection early 
+could kill the server
+
+=back
+
+=head2 HTTP::Server::Simple->new($port)
+
+API call to start a new server.  Does not actually start listening
+until you call C<-E<gt>run()>.
+
+=cut
+
+sub new {
+    my ( $proto, $port ) = @_;
+    my $class = ref($proto) || $proto;
+
+    if ( $class eq __PACKAGE__ ) {
+        require HTTP::Server::Simple::CGI;
+        return HTTP::Server::Simple::CGI->new( @_[ 1 .. $#_ ] );
+    }
+
+    my $self = {};
+    bless( $self, $class );
+    $self->port( $port || '8080' );
+
+
+
+    return $self;
+}
+
+
+=head2 lookup_localhost
+
+Looks up the local host's hostname and IP address.
+
+Stuffs them into
+
+$self->{'localname'} and $self->{'localaddr'}
+
+=cut
+
+sub lookup_localhost {
+    my $self = shift;
+
+    my $local_sockaddr = getsockname( $self->stdio_handle );
+    my ( undef, $localiaddr ) = sockaddr_in($local_sockaddr);
+    $self->host( gethostbyaddr( $localiaddr, AF_INET ) || "localhost");
+    $self->{'local_addr'} = inet_ntoa($localiaddr) || "127.0.0.1";
+}
+
+
+
+
+=head2 port [NUMBER]
+
+Takes an optional port number for this server to listen on.
+
+Returns this server's port. (Defaults to 8080)
+
+=cut
+
+sub port {
+    my $self = shift;
+    $self->{'port'} = shift if (@_);
+    return ( $self->{'port'} );
+
+}
+
+=head2 host [address]
+
+Takes an optional host address for this server to bind to.
+
+Returns this server's bound address (if any).  Defaults to C<undef>
+(bind to all interfaces).
+
+=cut
+
+sub host {
+    my $self = shift;
+    $self->{'host'} = shift if (@_);
+    return ( $self->{'host'} );
+
+}
+
+=head2 background
+
+Run the server in the background. returns pid.
+
+=cut
+
+sub background {
+    my $self  = shift;
+    my $child = fork;
+    die "Can't fork: $!" unless defined($child);
+    return $child if $child;
+    use POSIX;
+
+    if ( $^O !~ /MSWin32/ ) {
+        POSIX::setsid()
+            or die "Can't start a new session: $!";
+    }
+    $self->run();
+}
+
+=head2 run
+
+Run the server.  If all goes well, this won't ever return, but it will
+start listening for http requests.
+
+=cut
+
+my $server_class_id = 0;
+
+sub run {
+    my $self   = shift;
+    my $server = $self->net_server;
+
+    # Handle SIGHUP
+
+    local $SIG{CHLD} = 'IGNORE';    # reap child processes
+    local $SIG{HUP} = sub {
+
+        # XXX TODO: Autrijus says this code was incorrect when he wrote
+        # it and we should move to the sample code from perldoc perlipc
+        close HTTPDaemon;
+
+        # and then, on systems implementing fork(), we make sure
+        # we are running with a new pid, so another -HUP will still
+        # work on the new process.
+        require Config;
+        if ( $Config::Config{d_fork} and my $pid = fork() ) {
+
+            # finally, allow ^C on the parent process to terminate
+            # the children.
+            waitpid( $pid, 0 );
+            exit;
+        }
+
+        # do the exec. if $0 is not executable, try running it with $^X.
+        exec {$0}( ( ( -x $0 ) ? () : ($^X) ), $0, @ARGV );
+    } if exists $SIG{'HUP'};
+
+    # $pkg is generated anew for each invocation to "run"
+    # Just so we can use different net_server() implementations
+    # in different runs.
+    my $pkg = join '::', ref($self), "NetServer" . $server_class_id++;
+
+    no strict 'refs';
+    *{"$pkg\::process_request"} = $self->_process_request;
+
+    if ($server) {
+        require join( '/', split /::/, $server ) . '.pm';
+        *{"$pkg\::ISA"} = [$server];
+        $self->print_banner;
+    }
+    else {
+        $self->setup_listener;
+        *{"$pkg\::run"} = $self->_default_run;
+    }
+
+    $pkg->run( port => $self->port );
+}
+
+=head2 net_server
+
+User-overridable method. If you set it to a C<Net::Server> subclass,
+that subclass is used for the C<run> method.  Otherwise, a minimal 
+implementation is used as default.
+
+=cut
+
+sub net_server {undef}
+
+sub _default_run {
+    my $self = shift;
+
+    # Default "run" closure method for a stub, minimal Net::Server instance.
+    return sub {
+        my $pkg = shift;
+
+        $self->print_banner;
+
+        while (1) {
+            local $SIG{PIPE} = 'IGNORE';    # If we don't ignore SIGPIPE, a
+                 # client closing the connection before we
+                 # finish sending will cause the server to exit
+            while ( accept( my $remote, HTTPDaemon ) ) {
+                $self->stdio_handle($remote);
+                $self->lookup_localhost() unless ($self->host);
+                $self->accept_hook if $self->can("accept_hook");
+
+
+                *STDIN  = $self->stdin_handle();
+                *STDOUT = $self->stdout_handle();
+                select STDOUT;   # required for HTTP::Server::Simple::Recorder
+                                 # XXX TODO glasser: why?
+                $pkg->process_request;
+                close $remote;
+            }
+        }
+    };
+}
+
+sub _process_request {
+    my $self = shift;
+
+    # Create a callback closure that is invoked for each incoming request;
+    # the $self above is bound into the closure.
+    sub {
+
+        $self->stdio_handle(*STDIN) unless $self->stdio_handle;
+
+ # Default to unencoded, raw data out.
+ # if you're sending utf8 and latin1 data mixed, you may need to override this
+        binmode STDIN,  ':raw';
+        binmode STDOUT, ':raw';
+
+        my $remote_sockaddr = getpeername( $self->stdio_handle );
+        my ( undef, $iaddr ) = sockaddr_in($remote_sockaddr);
+        my $peeraddr = inet_ntoa($iaddr) || "127.0.0.1";
+
+        my ( $method, $request_uri, $proto ) = $self->parse_request
+            or do { $self->bad_request; return };
+
+        $proto ||= "HTTP/0.9";
+
+        my ( $file, $query_string )
+            = ( $request_uri =~ /([^?]*)(?:\?(.*))?/ );    # split at ?
+
+        if ( $method !~ /^(?:GET|POST|HEAD)$/ ) {
+            $self->bad_request;
+            return;
+        }
+
+        $self->setup(
+            method       => $method,
+            protocol     => $proto,
+            query_string => ( $query_string || '' ),
+            request_uri  => $request_uri,
+            path         => $file,
+            localname    => $self->host,
+            localport    => $self->port,
+            peername     => $peeraddr,
+            peeraddr     => $peeraddr,
+        );
+
+        # HTTP/0.9 didn't have any headers (I think)
+        if ( $proto =~ m{HTTP/(\d(\.\d)?)$} and $1 >= 1 ) {
+
+            my $headers = $self->parse_headers
+                or do { $self->bad_request; return };
+
+            $self->headers($headers);
+
+        }
+
+        $self->post_setup_hook if $self->can("post_setup_hook");
+
+        $self->handler;
+        }
+}
+
+
+
+
+
+=head2 stdio_handle [FILEHANDLE]
+
+When called with an argument, sets the socket to the server to that arg.
+
+Returns the socket to the server; you should only use this for actual socket-related
+calls like C<getsockname>.  If all you want is to read or write to the socket,
+you should use C<stdin_handle> and C<stdout_handle> to get the in and out filehandles
+explicitly.
+
+=cut
+
+sub stdio_handle {
+    my $self = shift;
+    $self->{'_stdio_handle'} = shift if (@_);
+    return $self->{'_stdio_handle'};
+}
+
+=head2 stdin_handle
+
+Returns a filehandle used for input from the client.  By default, 
+returns whatever was set with C<stdio_handle>, but a subclass
+could do something interesting here (see L<HTTP::Server::Simple::Logger>).
+
+=cut
+
+sub stdin_handle {
+    my $self = shift;
+    return $self->stdio_handle;
+}
+
+=head2 stdout_handle
+
+Returns a filehandle used for output to the client.  By default, 
+returns whatever was set with C<stdio_handle>, but a subclass
+could do something interesting here (see L<HTTP::Server::Simple::Logger>).
+
+=cut
+
+sub stdout_handle {
+    my $self = shift;
+    return $self->stdio_handle;
+}
+
+=head1 IMPORTANT SUB-CLASS METHODS
+
+A selection of these methods should be provided by sub-classes of this
+module.
+
+=head2 handler
+
+This method is called after setup, with no parameters.  It should
+print a valid, I<full> HTTP response to the default selected
+filehandle.
+
+=cut
+
+sub handler {
+    my ($self) = @_;
+    if ( ref($self) ne __PACKAGE__ ) {
+        croak "do not call " . ref($self) . "::SUPER->handler";
+    }
+    else {
+        die "handler called out of context";
+    }
+}
+
+=head2 setup(name =E<gt> $value, ...)
+
+This method is called with a name =E<gt> value list of various things
+to do with the request.  This list is given below.
+
+The default setup handler simply tries to call methods with the names
+of keys of this list.
+
+  ITEM/METHOD   Set to                Example
+  -----------  ------------------    ------------------------
+  method       Request Method        "GET", "POST", "HEAD"
+  protocol     HTTP version          "HTTP/1.1"
+  request_uri  Complete Request URI  "/foobar/baz?foo=bar"
+  path         Path part of URI      "/foobar/baz"
+  query_string Query String          undef, "foo=bar"
+  port         Received Port         80, 8080
+  peername     Remote name           "200.2.4.5", "foo.com"
+  peeraddr     Remote address        "200.2.4.5", "::1"
+  localname    Local interface       "localhost", "myhost.com"
+
+=cut
+
+sub setup {
+    my ($self) = @_;
+    while ( my ( $item, $value ) = splice @_, 0, 2 ) {
+        $self->$item($value) if $self->can($item);
+    }
+}
+
+=head2 headers([Header =E<gt> $value, ...])
+
+Receives HTTP headers and does something useful with them.  This is
+called by the default C<setup()> method.
+
+You have lots of options when it comes to how you receive headers.
+
+You can, if you really want, define C<parse_headers()> and parse them
+raw yourself.
+
+Secondly, you can intercept them very slightly cooked via the
+C<setup()> method, above.
+
+Thirdly, you can leave the C<setup()> header as-is (or calling the
+superclass C<setup()> for unknown request items).  Then you can define
+C<headers()> in your sub-class and receive them all at once.
+
+Finally, you can define handlers to receive individual HTTP headers.
+This can be useful for very simple SOAP servers (to name a
+crack-fueled standard that defines its own special HTTP headers). 
+
+To do so, you'll want to define the C<header()> method in your subclass.
+That method will be handed a (key,value) pair of the header name and the value.
+
+
+=cut
+
+sub headers {
+    my $self    = shift;
+    my $headers = shift;
+
+    my $can_header = $self->can("header");
+    while ( my ( $header, $value ) = splice @$headers, 0, 2 ) {
+        if ($can_header) {
+            $self->header( $header => $value );
+        }
+    }
+}
+
+=head2 accept_hook
+
+If defined by a sub-class, this method is called directly after an
+accept happens.
+
+=head2 post_setup_hook
+
+If defined by a sub-class, this method is called after all setup has
+finished, before the handler method.
+
+=head2  print_banner
+
+This routine prints a banner before the server request-handling loop
+starts.
+
+Methods below this point are probably not terribly useful to define
+yourself in subclasses.
+
+=cut
+
+sub print_banner {
+    my $self = shift;
+
+    print(    __PACKAGE__
+            . ": You can connect to your server at "
+            . "http://localhost:"
+            . $self->port
+            . "/\n" );
+
+}
+
+=head2 parse_request
+
+Parse the HTTP request line.
+
+Returns three values, the request method, request URI and the protocol
+Sub-classed versions of this should return three values - request
+method, request URI and proto
+
+=cut
+
+sub parse_request {
+    my $self = shift;
+    my $chunk;
+    while ( sysread( STDIN, my $buff, 1 ) ) {
+        last if $buff eq "\n";
+        $chunk .= $buff;
+    }
+    defined($chunk) or return undef;
+    $_ = $chunk;
+
+    m/^(\w+)\s+(\S+)(?:\s+(\S+))?\r?$/;
+    my $method   = $1 || '';
+    my $uri      = $2 || '';
+    my $protocol = $3 || '';
+
+    return ( $method, $uri, $protocol );
+}
+
+=head2 parse_headers
+
+Parse incoming HTTP headers from STDIN.
+
+Remember, this is a B<simple> HTTP server, so nothing intelligent is
+done with them C<:-)>.
+
+This should return an ARRAY ref of C<(header =E<gt> value)> pairs
+inside the array.
+
+=cut
+
+sub parse_headers {
+    my $self = shift;
+
+    my @headers;
+
+    my $chunk = '';
+    while ( sysread( STDIN, my $buff, 1 ) ) {
+        if ( $buff eq "\n" ) {
+            $chunk =~ s/[\r\l\n\s]+$//;
+            if ( $chunk =~ /^([\w\-]+): (.+)/i ) {
+                push @headers, $1 => $2;
+            }
+            last if ( $chunk =~ /^$/ );
+            $chunk = '';
+        }
+        else { $chunk .= $buff }
+    }
+
+    return ( \@headers );
+}
+
+=head2 setup_listener
+
+This routine binds the server to a port and interface.
+
+=cut
+
+sub setup_listener {
+    my $self = shift;
+
+    my $tcp = getprotobyname('tcp');
+
+    socket( HTTPDaemon, PF_INET, SOCK_STREAM, $tcp ) or die "socket: $!";
+    setsockopt( HTTPDaemon, SOL_SOCKET, SO_REUSEADDR, pack( "l", 1 ) )
+        or warn "setsockopt: $!";
+    bind( HTTPDaemon,
+        sockaddr_in(
+            $self->port(),
+            (   $self->host
+                ? inet_aton( $self->host )
+                : INADDR_ANY
+            )
+        )
+        )
+        or die "bind: $!";
+    listen( HTTPDaemon, SOMAXCONN ) or die "listen: $!";
+
+}
+
+=head2 bad_request
+
+This method should print a valid HTTP response that says that the
+request was invalid.
+
+=cut
+
+our $bad_request_doc = join "", <DATA>;
+
+sub bad_request {
+    my $self = shift;
+
+    print "HTTP/1.0 400 Bad request\r\n";    # probably OK by now
+    print "Content-Type: text/html\r\nContent-Length: ",
+        length($bad_request_doc), "\r\n\r\n", $bad_request_doc;
+}
+
+=head1 AUTHOR
+
+Copyright (c) 2004-2005 Jesse Vincent, <jesse at bestpractical.com>.
+All rights reserved.
+
+Marcus Ramberg <drave at thefeed.no> contributed tests, cleanup, etc
+
+Sam Vilain, <samv at cpan.org> contributed the CGI.pm split-out and
+header/setup API.
+
+=head1 BUGS
+
+There certainly are some. Please report them via rt.cpan.org
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
+
+__DATA__
+<html>
+  <head>
+    <title>Bad Request</title>
+  </head>
+  <body>
+    <h1>Bad Request</h1>
+
+    <p>Your browser sent a request which this web server could not
+      grok.</p>
+  </body>
+</html>


Property changes on: packages/libhttp-server-simple-perl/branches/upstream/current/lib/HTTP/Server/Simple.pm
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libhttp-server-simple-perl/branches/upstream/current/t/00smoke.t
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/t/00smoke.t	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/t/00smoke.t	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,11 @@
+use Test::More tests=>8;
+
+use_ok(HTTP::Server::Simple);
+ok(HTTP::Server::Simple->can('new'), 'can new()');
+my $s= HTTP::Server::Simple->new();
+isa_ok($s,'HTTP::Server::Simple');
+is($s->port(),8080,'Defaults to 8080');
+is($s->port(13432),13432,'Can change port');
+is($s->port(),13432,'Change persists');
+ok($s->can('print_banner'), 'can print_banner()');
+ok($s->can('run'), 'can run()');

Added: packages/libhttp-server-simple-perl/branches/upstream/current/t/01live.t
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/t/01live.t	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/t/01live.t	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,128 @@
+# -*- perl -*-
+
+use Socket;
+use Test::More tests => 10;
+use strict;
+
+# This script assumes that `localhost' will resolve to a local IP
+# address that may be bound to,
+
+use constant PORT => 13432;
+
+use HTTP::Server::Simple;
+
+my $DEBUG = 1 if @ARGV;
+
+{
+    my $s=HTTP::Server::Simple->new(PORT);
+    is($s->port(),PORT,"Constructor set port correctly");
+
+    my $pid=$s->background();
+
+    like($pid, qr/^-?\d+$/,'pid is numeric');
+    select(undef,undef,undef,0.2); # wait a sec
+
+    my $content=fetch("GET / HTTP/1.1", "");
+
+    like($content, qr/Congratulations/, "Returns a page");
+    is(kill(9,$pid),1,'Signaled 1 process successfully');
+    wait or die "couldn't wait for sub-process completion";
+}
+
+{
+    my $s=HTTP::Server::Simple::CGI->new(PORT);
+    $s->host("localhost");
+    my $pid=$s->background();
+    diag("started server on $pid");
+    select(undef,undef,undef,0.2); # wait a sec
+    like($pid, qr/^-?\d+$/,'pid is numeric');
+
+    my $content=fetch("GET / HTTP/1.1", "");
+    like($content,qr/Congratulations/,"Returns a page");
+
+    eval {
+	like(fetch("GET your mum wet"),  # anything does!
+	     qr/bad request/i,
+	     "knows what a request isn't");
+    };
+    fail("got exception in client: $@") if $@;
+
+    like(fetch("GET / HTTP/1.1", ""), qr/Congratulations/,
+	 "HTTP/1.1 request");
+
+    like(fetch("GET /"), qr/Congratulations/,
+	 "HTTP/0.9 request");
+
+    is(kill(9,$pid),1,'Signaled 1 process successfully');
+}
+
+# this function may look excessive, but hopefully will be very useful
+# in identifying common problems
+sub fetch {
+
+    my @response;
+    my $alarm = 0;
+    my $stage = "init";
+
+    my %messages =
+	( "init" => "inner contemplation",
+	  "lookup" => ("lookup of `localhost' - may be caused by a "
+		       ."missing hosts entry or broken resolver"),
+	  "sockaddr" => "call to sockaddr_in() - ?",
+	  "proto" => ("call to getprotobyname() - may be caused by "
+		      ."bizarre NSS configurations"),
+	  "socket" => "socket creation",
+	  "connect" => ("connect() - may be caused by a missing or "
+			."broken loopback interface, or firewalling"),
+	  "send" => "network send()",
+	  "recv" => "collection of response",
+	  "close" => "closing socket"
+	);
+
+    $SIG{ALRM} = sub {
+	@response = "timed out during $messages{$stage}";
+	$alarm = 1;
+    };
+
+    my ($iaddr, $paddr, $proto, $message);
+
+    $message = join "", map { "$_\015\012" } @_;
+
+    my %states =
+	( 'init'     => sub { "lookup"; },
+	  "lookup"   => sub { ($iaddr = inet_aton("localhost"))
+				  && "sockaddr"			    },
+	  "sockaddr" => sub { ($paddr = sockaddr_in(PORT, $iaddr))
+				  && "proto"			    },
+	  "proto"    => sub { ($proto = getprotobyname('tcp'))
+				  && "socket"			    },
+	  "socket"   => sub { socket(SOCK, PF_INET, SOCK_STREAM, $proto)
+				  && "connect"			    },
+	  "connect"  => sub { connect(SOCK, $paddr) && "send"	    },
+	  "send"     => sub { (send SOCK, $message, 0) && "recv"    },
+	  "recv"     => sub {
+	      my $line;
+	      while (!$alarm and defined($line = <SOCK>)) {
+		  push @response, $line;
+	      }
+	      ($alarm ? undef : "close");
+	  },
+	  "close"    => sub { close SOCK; "done"; },
+	);
+
+    # this entire cycle should finish way before this timer expires
+    alarm(5);
+
+    my $next;
+    $stage = $next
+	while (!$alarm && $stage ne "done"
+	       && ($next = $states{$stage}->()));
+
+    warn "early exit from `$stage' stage; $!" unless $next;
+
+    # bank on the test testing for something in the response.
+    return join "", @response;
+
+
+}
+

Added: packages/libhttp-server-simple-perl/branches/upstream/current/t/02pod.t
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/t/02pod.t	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/t/02pod.t	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,9 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();
+

Added: packages/libhttp-server-simple-perl/branches/upstream/current/t/03podcoverage.t
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/t/03podcoverage.t	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/t/03podcoverage.t	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,9 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Test::More;
+
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok({  also_private => [ qr/^[A-Z_]+$/ ], });
+

Added: packages/libhttp-server-simple-perl/branches/upstream/current/t/04cgi.t
===================================================================
--- packages/libhttp-server-simple-perl/branches/upstream/current/t/04cgi.t	2006-03-17 22:34:04 UTC (rev 2419)
+++ packages/libhttp-server-simple-perl/branches/upstream/current/t/04cgi.t	2006-03-17 22:36:34 UTC (rev 2420)
@@ -0,0 +1,161 @@
+use Test::More tests => 20;
+use Socket;
+use strict;
+
+use constant PORT => 13432;
+my $host = gethostbyaddr(inet_aton('localhost'), AF_INET);
+
+our %methods=(
+              url => "url: http://$host:".PORT,
+              path_info => 'path_info: /cgitest/path_info',
+              server_name => "server_name: $host",
+              server_port => 'server_port: '.PORT,
+              server_software => 'server_software: HTTP::Server::Simple/\d+.\d+',
+              request_method => 'request_method: GET',
+            );
+
+our %envvars=(
+              SERVER_URL => "SERVER_URL: http://$host:".PORT.'/',
+              SERVER_PORT => 'SERVER_PORT: '.PORT,
+              REQUEST_METHOD => 'REQUEST_METHOD: GET',
+              REQUEST_URI => 'REQUEST_URI: /cgitest/REQUEST_URI',
+              SERVER_PROTOCOL => 'SERVER_PROTOCOL: HTTP/1.1',
+              SERVER_NAME => "SERVER_NAME: $host",
+              SERVER_SOFTWARE => 'SERVER_SOFTWARE: HTTP::Server::Simple/\d+.\d+',
+              REMOTE_ADDR => 'REMOTE_ADDR: 127.0.0.1',
+              QUERY_STRING => 'QUERY_STRING: ',
+              PATH_INFO => 'PATH_INFO: /cgitest/PATH_INFO',
+            );
+
+{
+  my $server=CGIServer->new(PORT);
+  is($server->port(),PORT,'Constructor set port correctly');
+  select(undef,undef,undef,0.2); # wait a sec
+
+  my $pid=$server->background;
+
+  like($pid,qr/^-?\d+$/,'pid is numeric');
+
+  select(undef,undef,undef,0.2); # wait a sec
+  like(fetch("GET / HTTP/1.1",""),qr(NOFILE),'no file');
+
+  foreach my $method (keys(%methods)) {
+    like(
+          fetch("GET /cgitest/$method HTTP/1.1",""),
+          qr($methods{$method}),
+          "method - $method"
+        );
+    select(undef,undef,undef,0.2); # wait a sec
+  }
+
+  foreach my $envvar (keys(%envvars)) {
+    like(
+          fetch("GET /cgitest/$envvar HTTP/1.1",""),
+          qr($envvars{$envvar}),
+          "Environment - $envvar"
+        );
+    select(undef,undef,undef,0.2); # wait a sec
+  }
+
+  is(kill(9,$pid),1,'Signaled 1 process successfully');
+  wait or die "counldn't wait for sub-process completion";
+}
+
+
+sub fetch {
+
+    my @response;
+    my $alarm = 0;
+    my $stage = "init";
+
+    my %messages =
+	( "init" => "inner contemplation",
+	  "lookup" => ("lookup of `localhost' - may be caused by a "
+		       ."missing hosts entry or broken resolver"),
+	  "sockaddr" => "call to sockaddr_in() - ?",
+	  "proto" => ("call to getprotobyname() - may be caused by "
+		      ."bizarre NSS configurations"),
+	  "socket" => "socket creation",
+	  "connect" => ("connect() - may be caused by a missing or "
+			."broken loopback interface, or firewalling"),
+	  "send" => "network send()",
+	  "recv" => "collection of response",
+	  "close" => "closing socket"
+	);
+
+    $SIG{ALRM} = sub {
+	@response = "timed out during $messages{$stage}";
+	$alarm = 1;
+    };
+
+    my ($iaddr, $paddr, $proto, $message);
+
+    $message = join "", map { "$_\015\012" } @_;
+
+    my %states =
+	( 'init'     => sub { "lookup"; },
+	  "lookup"   => sub { ($iaddr = inet_aton("localhost"))
+				  && "sockaddr"			    },
+	  "sockaddr" => sub { ($paddr = sockaddr_in(PORT, $iaddr))
+				  && "proto"			    },
+	  "proto"    => sub { ($proto = getprotobyname('tcp'))
+				  && "socket"			    },
+	  "socket"   => sub { socket(SOCK, PF_INET, SOCK_STREAM, $proto)
+				  && "connect"			    },
+	  "connect"  => sub { connect(SOCK, $paddr) && "send"	    },
+	  "send"     => sub { (send SOCK, $message, 0) && "recv"    },
+	  "recv"     => sub {
+	      my $line;
+	      while (!$alarm and defined($line = <SOCK>)) {
+		  push @response, $line;
+	      }
+	      ($alarm ? undef : "close");
+	  },
+	  "close"    => sub { close SOCK; "done"; },
+	);
+
+    # this entire cycle should finish way before this timer expires
+    alarm(5);
+
+    my $next;
+    $stage = $next
+	while (!$alarm && $stage ne "done"
+	       && ($next = $states{$stage}->()));
+
+    warn "early exit from `$stage' stage; $!" unless $next;
+
+    # bank on the test testing for something in the response.
+    return join "", @response;
+
+
+}
+
+{
+  package CGIServer;
+  use base qw(HTTP::Server::Simple::CGI);
+  use Env;
+  use Data::Dumper;
+
+
+  sub handle_request {
+    my $self=shift;
+    my $cgi=shift;
+
+
+    my $file=(split('/',$cgi->path_info))[-1]||'NOFILE';
+    $file=~s/\s+//g;
+    $file||='NOFILE';
+    print "HTTP/1.0 200 OK\r\n";    # probably OK by now
+    print "Content-Type: text/html\r\nContent-Length: ";
+    my $response;
+    if($methods{$file}) {
+      $response="$file: ".$cgi->$file;
+    } elsif($envvars{$file}) {
+      $response="$file: $ENV{$file}";
+    } else {
+      $response=$file;
+    }
+    print length($response), "\r\n\r\n", $response;
+  }
+}
+




More information about the Pkg-perl-cvs-commits mailing list