The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
#!/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);