On Thu, Oct 17, 2002 at 01:07:48PM -0500, Bob Maccione wrote:
> I've taken the cookbook examples for the web server (the forking one is
> rather cool) and am wondering if anyone has fully implementated a web server
> and if so are they willing to release the code?
> 
> I've hacked together parts, I can tell if the user is requesting a .pl and
> if so I eval it (this is totally internal so I'm not too concerned about
> security yet), etc but I'm probably missing some stuff.
> 
> here is what I've added to the forked web server example:

[...]

Have you looked at POE::Component::Server::HTTP?  You might be able to
create a package of standard request handlers for it.

> it's not the greatest but I'm wondering what everyone has done..

I haven't written a generic web server.  It's just been too easy to
put together single-purpose web applications.

Two of my IRC bots have web interfaces:

  http://sf.net/projects/memephage
  http://sf.net/projects/pastebot

Memephage includes something like this interesting bit of code.  If
you ever need to implement basic authentication, here's how:

  my ($login, $password) = $request->authorization_basic();
  $login = "" unless defined $login;
  $password = "" unless defined $password;

  unless (valid_password($login, $password)) {
    my $response = new HTTP::Response(401);
    $response->push_header('WWW-Authenticate', 'Basic realm="memephage"');
    $response->push_header('Server', 'memephage/1.0');
    $response->push_header('Content-Type', 'text/html');
    $response->content("You aren't allowed in.");
    $heap->{wheel}->put($response);
    return;
  }

Everything beyond that block of code will be password protected.

-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sf.net

Reply via email to