bkiahg has asked for the wisdom of the Perl Monks concerning the following question:
It's very possible I am misunderstanding the send_response function or how to interact with it.use HTTP::Daemon; use HTTP::Status; my $d = HTTP::Daemon->new(Listen => 5, LocalAddr => 'localhost', LocalPort => 80, Proto => 'tcp') or die "Can't bin +d : $@\n"; print "Please contact me at: <URL:", $d->url, ">\n"; while (my $c = $d->accept) { while (my $r = $c->get_request) { if ($r->method eq 'GET') { # dies right on this line $c->send_response("Content-type: text/html\n\nHello Worl +d"); } else { $c->send_error(RC_FORBIDDEN) } } $c->close; undef($c); }
use HTTP::Daemon; use HTTP::Status; require 'C:\\rrships\\default.cgi'; my $d = HTTP::Daemon->new(Listen => 5, LocalAddr => 'localhost', LocalPort => 80, Proto => 'tcp') or die "Can't bin +d : $@\n"; # print "Please contact me at: <URL:", $d->url, ">\n"; while (my $c = $d->accept) { while (my $r = $c->get_request) { # print $r->url->path . "\n"; if ($r->method eq 'GET') { my $response = HTTP::Response->new(200); $response->content(&Hello_World($r->url->path, $r->url-> +query)); $response->header("Content-Type" => "text/html"); $c->send_response($response); } else { $c->send_error(RC_FORBIDDEN) } } $c->close; undef($c); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTTP::Daemon send_response Problem
by talexb (Chancellor) on Dec 29, 2008 at 08:53 UTC | |
|
Re: HTTP::Daemon send_response Problem
by afresh1 (Hermit) on Dec 29, 2008 at 21:53 UTC |