File: httpd_term.pl

package info (click to toggle)
libhttp-daemon-perl 6.01-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 276 kB
  • sloc: perl: 790; makefile: 2
file content (25 lines) | stat: -rwxr-xr-x 515 bytes parent folder | download | duplicates (2)
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
#!/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;
}