From 64ffbaec18717f99cb80441d8b474868e39939fb Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Sat, 18 Feb 2012 12:24:17 +0000 Subject: HTTP-Daemon-6.01 --- t/misc/httpd | 31 +++++++++++++++++++++++++++++++ t/misc/httpd_term.pl | 25 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100755 t/misc/httpd create mode 100755 t/misc/httpd_term.pl (limited to 't/misc') diff --git a/t/misc/httpd b/t/misc/httpd new file mode 100755 index 0000000..f17a2bf --- /dev/null +++ b/t/misc/httpd @@ -0,0 +1,31 @@ +#!/local/perl/bin/perl -w + +use HTTP::Daemon (); + +my $s = new HTTP::Daemon; +die "Can't create daemon: $!" unless $s; + +print $s->url, "\n"; + +my $c = $s->accept; +die "Can't accept" unless $c; + +$c->timeout(60); +my $req = $c->get_request; + +die "No request" unless $req; + +my $abs = $req->uri->abs; + +print $req->as_string; + +$c->send_file_response("/etc"); + +#$c->send_redirect("http://www.sn.no/aas", 301, "Piss off"); + +#my $res = HTTP::Response->new(400, undef, +# HTTP::Headers->new(Foo => 'bar'), +# "Gisle\n" +# ); +#$c->send_response($res); + diff --git a/t/misc/httpd_term.pl b/t/misc/httpd_term.pl new file mode 100755 index 0000000..ce38c22 --- /dev/null +++ b/t/misc/httpd_term.pl @@ -0,0 +1,25 @@ +#!/local/perl/bin/perl + +use HTTP::Daemon; +#$HTTP::Daemon::DEBUG++; + +my $d = HTTP::Daemon->new(Timeout => 60); +print "Please contact me at: url, ">\n"; + +while (my $c = $d->accept) { + CONNECTION: + while (my $r = $c->get_request) { + print $r->as_string; + $c->autoflush; + RESPONSE: + while () { + last RESPONSE if $_ eq ".\n"; + last CONNECTION if $_ eq "..\n"; + print $c $_; + } + print "\nEOF\n"; + } + print "CLOSE: ", $c->reason, "\n"; + $c->close; + $c = undef; +} -- cgit v1.2.1