in reply to Re: CGI Parameters
in thread CGI Parameters

I'd assume that HTTP header variables means it's sent in the HTTP header or possibly as a cookie. Don't know if the CGI http() method will get you access to arbitrary header settings; perhaps it depends on what web server you are using. For cookies, see CGI.

A quick look at the source reveals CGI's http() method just looks for environment variables starting with HTTP.

Update: as 3dan and etcshadow say, the server uppercases the header labels and prepends HTTP_ to make them available in the environment. (I wonder if this is actually reliable for arbitrary headers on all servers.)

Replies are listed 'Best First'.
Re: Re: Re: CGI Parameters
by edan (Curate) on Jan 12, 2004 at 12:11 UTC

    The CGI->http method lets you access those environment variables starting with 'HTTP', yes. But what you seem to be missing is that those environment variables are set by the webserver to the value of the HTTP headers sent in the request. For example, if you sent this request to you CGI:

    GET /my_cgi.pl HTTP/1.1
    Host: localhost
    Foo: FOO Content here
    
    

    ...then the following code should get you the value 'FOO Content here':

    use CGI; my $q = CGI->new; my $foo_content = $q->http("Foo"); # or $q->http("HTTP_FOO")

    Update: I see that etcshadow dealt with this in full elsewhere in the thread... hey, a little repetition never hurt anybody, right?

    --
    3dan