R.A. Epigonos et al.

HTTP::Daemonで簡単なhttpサーバ

use HTTP::Daemon;
use HTTP::Status;
my $d = new HTTP::Daemon;
$d = new HTTP::Daemon
  LocalAddr => '',
  LocalPort => 80;
print "Please contact me at: <URL:", $d->url, ">\n";
while (my $c = $d->accept) {
  while (my $r = $c->get_request) {
  warn $r->as_string;
    if ($r->method eq 'GET' and $r->url->path eq "/") {
        $c->send_file_response("./Dd21.txt");
    } else {
        $c->send_error(RC_FORBIDDEN)
    }
  }
  $c->close;
  undef($c);
}
exit;
D:\test>perl -w http_deamon_deamon.pl
Please contact me at: <URL:http://eizi/>
GET / HTTP/1.1
Connection: Keep-Alive
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: ja
Host: 219.209.188.83
If-Modified-Since: Tue, 27 Sep 2005 08:00:00 GMT
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; Lunascape 2.0.3)

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2007-09-28T04:20:07+09:00
  2. Modified: 2007-09-28T04:19:14+09:00
  3. Generated: 2023-08-27T23:09:12+09:00