in reply to Advice on HTTPServer problem please

Hi,

From the POD of the module:

$server->RegisterURL("/foo/bar.pl",\&test); sub test { my $req = shift; # Net::HTTPServer::Request object my $res = $req->Response(); # Net::HTTPServer::Response object $res->Print("<html>\n"); $res->Print(" <head>\n"); $res->Print(" <title>This is a test</title>\n"); $res->Print(" </head>\n"); $res->Print(" <body>\n"); $res->Print(" <pre>\n"); foreach my $var (keys(%{$req->Env()})) { $res->Print("$var -> ".$req->Env($var)."\n"); } $res->Print(" </pre>\n"); $res->Print(" </body>\n"); $res->Print("</html>\n"); return $res; }

You are mixing things together... for example:

On sub test you don't get the $ENV var, what you get is the Request object.

After calling $server->Process() you enter in a loop so the next statement won't be executed

You're not authenticating, you want to send a HTML page answer to a client, so you only need to print to STDOUT = client the html output

You can print the port listening on, after calling the Start() method, but not after calling Process() without giving a timeout value...

Better take a second look at the module doc. ;-)

Regards,

:-)

Update: don't know exactly what you wanna do, but I recommend you, taking a look at POE, at http://poe.perl.org

Replies are listed 'Best First'.
Re^2: Advice on HTTPServer problem please
by jdtoronto (Prior) on Jun 28, 2005 at 21:49 UTC
    Just shows you shouldn't always assume that the example in the POD will run! Thanks for the advice. I will look at POE also.

    jdtoronto