Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Serve local perl docs with HTTP::Daemon

by jfroebe (Parson)
on Oct 11, 2004 at 20:17 UTC ( [id://398281]=note: print w/replies, xml ) Need Help??


in reply to •Re: Serve local perl docs with HTTP::Daemon
in thread Serve local perl docs with HTTP::Daemon

a little better.... added $r->url->path =~ s!../!!g;

#!/usr/bin/perl use strict; use warnings; use HTTP::Daemon; use HTTP::Status; my $perldocs = 'c:/Perl/html/'; my $n = "\n"; my $d = HTTP::Daemon->new(LocalAddr=>'localhost',LocalPort=>83) || die +; print "Listening on: <URL:", $d->url, ">\n"; while (my $c = $d->accept) { while (my $r = $c->get_request) { $r->url->path =~ s!../!!g; print $r->method." ".$r->url->path.$n; if ($r->method eq 'GET') { -e $perldocs.$r->url->path ? $c->send_file_response($perldocs.$r->url->path) : $c->send_error(RC_NOT_FOUND); } else { $c->send_error(RC_FORBIDDEN) } } $c->close; undef($c); }

No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://398281]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2024-04-23 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found