LPM: CGI question
Joe Hourcle
oneiros at dcr.net
Thu Jan 11 16:04:58 CST 2001
On Thu, 11 Jan 2001, Janine wrote:
> I'm trying to figure out the best way of telling whether a script was
> invoked through a browser or from the command line. Right now I'm
> checking if ENV{"HTTP_HOST"} exists (yes = browser; no = command
> line). Does anyone know of a better way to do this?
Technically, HTTP_HOST is set only by browsers which support software
virtual hosts. [As first generation browsers don't send a Host: header]
Unless you know your server will set HTTP_HOST to null if they don't send
the header [mine won't -- an old Netscape Enterprise 3.0 server], you'd be
better off checking something that's more likely to be there:
REMOTE_ADDR
REQUEST_METHOD
SERVER_NAME
SERVER_PROTOCOL
Personally, I go with REMOTE_ADDR, as it's needed for the web server to
reply back to the browser.
-----
Joe Hourcle
More information about the Lexington-pm
mailing list