summaryrefslogtreecommitdiff
path: root/t/misc
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2012-02-18 12:24:17 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2012-02-18 12:24:17 +0000
commit64ffbaec18717f99cb80441d8b474868e39939fb (patch)
treea44be040c9ca4b95ee54736e1f9bd1897b9b5160 /t/misc
downloadHTTP-Daemon-tarball-master.tar.gz
Diffstat (limited to 't/misc')
-rwxr-xr-xt/misc/httpd31
-rwxr-xr-xt/misc/httpd_term.pl25
2 files changed, 56 insertions, 0 deletions
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, "<title>Piss off</title>");
+
+#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:", $d->url, ">\n";
+
+while (my $c = $d->accept) {
+ CONNECTION:
+ while (my $r = $c->get_request) {
+ print $r->as_string;
+ $c->autoflush;
+ RESPONSE:
+ while (<STDIN>) {
+ last RESPONSE if $_ eq ".\n";
+ last CONNECTION if $_ eq "..\n";
+ print $c $_;
+ }
+ print "\nEOF\n";
+ }
+ print "CLOSE: ", $c->reason, "\n";
+ $c->close;
+ $c = undef;
+}