in reply to write a small Perl HTTP server

They probably don't get much smaller than this "one-liner" from the IO::All pod.

# A single statement web server for static files and cgis too io(":8080") ->accept("-fork") ->( sub { $_[0] < io( -x $1 ? "./$1 |" : $1) if /^GET \/(.*) / } );
I'm not sure how well, or even if it works, but...it comes with a good pedigree.

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re^2: write a small Perl HTTP server
by samtregar (Abbot) on Jul 08, 2004 at 19:58 UTC
    Funny stuff! That won't work for CGIs though. It doesn't set up the CGI environment variables.

    -sam

Re^2: write a small Perl HTTP server
by gaal (Parson) on Jul 08, 2004 at 20:01 UTC
    Uh, that regexp can't be right. For one thing, the argument to GET is a URL and doesn't have to start with a slash; and there's usually an HTTP version string afterwards.
      The argument does start with a slash if your "server" is not working as a proxy, and the HTTP string comes after the space, which is also matched with the regex.
        No, that's incorrect:

        The HTTP RFC (2616) defines the Request-Line thus (section 5.1):

        Request-Line   = Method SP Request-URI SP HTTP-Version CRLF

        And Request-URI thus:

        Request-URI    = "*" | absoluteURI | abs_path | authority

        So although you *may* supply an absolute path as an argument to GET, you may also supply a URI; in fact, you'll see that that's what virtually all clients send, because otherwise virtual hosts will be broken.