File: httpd

package info (click to toggle)
libhttp-daemon-perl 6.12-1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 492 kB
  • sloc: perl: 715; makefile: 2
file content (28 lines) | stat: -rwxr-xr-x 542 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use HTTP::Daemon ();

my $s = HTTP::Daemon->new();
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);