Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
It's ok, but when I try to browse it, it show me the broken pipes, but don't exit. But some images don't load in the browser. So, I try to reload the page sometimes and then, seems that it stops working (but still running in the console). What is happening? Thanksuse strict; use HTTP::Daemon; use HTTP::Status; $SIG{PIPE}='go_away'; sub go_away { print "Broken Pipe detected\n" } my $html_docs = "/var/www/html"; open LOG, ">> webserver.log" or die "Unable to open log\n"; LOG->autoflush(1); my $d = HTTP::Daemon->new( LocalAddr => 'localhost', LocalPort => 8080, ) or die; print "Listening...\n"; while (my $c = $d->accept) { while (my $r = $c->get_request) { my $url = $r->url->path; print LOG "$url"; if ($r->method eq 'GET' and $r->url->path eq "/") { $c->send_file_response("$html_docs/index.html"); } elsif ($r->method eq 'GET') { $c->send_file_response("$html_docs$url"); } else { $c->send_error(RC_FORBIDDEN) } } $c->close; undef($c); }
2006-05-05 Retitled by Corion, as per Monastery guidelines
Original title: 'Webserver'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTTP::Daemon webserver keeps breaking
by shonorio (Hermit) on May 05, 2006 at 20:02 UTC | |
|
Re: HTTP::Daemon webserver keeps breaking
by philcrow (Priest) on May 05, 2006 at 21:08 UTC |