Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Simple HTTP in under 100 lines

by mattr (Curate)
on Nov 13, 2001 at 20:00 UTC ( [id://125067]=note: print w/replies, xml ) Need Help??


in reply to Simple HTTP in under 100 lines

Interesting! Here's what I got.. - had trouble running it with -wT in line 1; was able to run it after cutting that out as you suggest, perl -wT perlsvr.pl perlsvrhome
- could not get -h to work (I think this and above mean my getopts or something is corrupt)

- does not close connection right away though kills child.
- sending ctrl-c instead of something like GET / causes child to quit with "Use of uninitialized value at /usr/lib/perl5/site_perl/5.005/HTTP/Daemon.pm line 498." which is a funny reason to quit..
- was able to download a file set to chmod 700 and ending in .pl

So I'm not so sure about the security side, although presumably perl's proof against buffer attacks, we are told. How about keeping a list of children and killing them after a certain amount of time just in case? I wanted to do a kill -HUP on it when I had made a lot of children processes, but it just died.

The

Replies are listed 'Best First'.
Re: Re: Simple HTTP in under 100 lines
by Corion (Patriarch) on Nov 13, 2001 at 20:17 UTC

    I use PSI::ESP to address the errors :-)

    • Trouble with running the server without -T on the command line - I get this error every time I try to use taint mode : Too late for -T. I don't know about any way around it except specifying -T on the command line.
    • -h dosen't work. - There is no -h option, so it won't work.
    • Connections are not always closed when a child exits. I'm not sure when this happens - my experience showed that IE kept a child alive until either some timeout happened or I closed that IE window (or visited another URL with that window)
    • Sending ^C to the server gives a funny error message - This is a "problem" with HTTP::Daemon which seems to want to call a ^C (instead of GET) method. I don't know how to fix this without patching HTTP::Daemon.
    • .pl files will be downloaded, even though they are executable and only readable by the user running the webserver. - This works as designed. Everything below the webserver root is exported, and as long as the user under which the webserver is run can read the file it will transfer that file. Note that especially no execution of files is possible.

    I'm not keen to add any more features to that server as it would transcend both the line count limit and the complexity limit - also, this server is used to stream 200MB files over my meager 128kbit line, so each child lives a very long time.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-25 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found