Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: http header parsing in perl



Believe it or not, Jonathan has a programming question  :-)

I've been asked to write a Perl CGI to do the following:

1) Be called by the web server in cases of a 403 or 404;

2) Parse the http header and extract the customer's web directory (this
is for virtual hosting customers), then check in that directory to
see if the customer has a custom page for this situation present (these
will have default titles, which I plan to call 403.html and 404.html);

3) If the appropriate 403.html or 404.html page is not present in the
customer's directory, serve up a default one from elsewhere.

OK, so I'm a Perl beginner (currently reading the Llama book) and step 2
seems a bit beyond me.  I'm not sure just what form the http header
will have and what I should read to find out;  Is the http header
available in an environment variable or something, that the CGI can get
it from there?  If so, what variable?  If not, how can I bring it into
the script?

Also, there is a huge pile of stuff on CPAN, and I can't help thinking
that somewhere in there is something that may already do this, but I'm
not sure where to look.  If anybody has any Perl code that is already
doing this (or soemthing similar), I'd love to get to take a look at it
and see how it works, maybe borrow some or all of it, if that's OK.

Once I know what the header looks like and how to get it, isolating
whether it is a 403 or 404, and grabbing the customer's web directory
from it and checking for the existence of the right file seems
relatively straightforward (I hope that's an accurate perception :-)  ).
One question, though: would it be better to do this with one script that
checks whether it's a 403 or a 404, or just use two different scripts?


Thanks!

Jonathan Byrne                                   Engineering Division
Global Online Japan                              http://www.gol.com/
Tel:  +81 03-5334-1700   Fax: +81-03-5334-1701   Direct: +81-03-5334-1756


-------------------------------------------------------------------
Next Nomikai: TBD                    Tengu TokyoEkiMae 03-3275-3691
Next Technical Meeting: June 12 (Sat), 12  :30   place: Temple Univ.
-------------------------------------------------------------------
more info: http://www.tlug.gr.jp        Sponsor: Global Online Japan


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links