use strict; use warnings; use Cwd; use lib getcwd; use HTTP::Daemon; use SDaemon; use HTTP::Status; use IO::Select; use Data::Dumper; # Create a client connection object "the hard way" my $c = HTTP::Daemon::ClientConn->new_from_fd ('STDIN', "+>"); # backfill the necessary client connection attributes ${*$c}{'httpd_daemon'} = SDaemon->new(); binmode $c; $c->autoflush(1); close STDIN; my $i = 0; while (my $req = $c->get_request()) { print STDERR "$$] $i Request\n".$req->as_string."\n"; my $content = "Pid: $$ ".(scalar localtime()).""; my $hdrs = HTTP::Headers->new(('Content-Length' => length($content))); my $res = HTTP::Response->new(RC_OK,'',$hdrs,$content); $c->send_response($res); print STDERR "$$] $i sent response\n"; } $c->close;