For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > April 2005 > About unoffical HTTP headers









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author About unoffical HTTP headers
Shu Cao

2005-04-26, 3:55 pm

Hi,

Sorry, my last email has some errors. The unofficial HTTP header should
look like "x: y" not "x=y".

I am new to Perl CGI programming. And I encounter a difficult problem
wish you guys can help me. Thank you! Here is the problem, how can Perl
CGI program get the unofficial HTTP header value like "x: y". I examine
the %ENV hash, and found nothing but some standard HTTP headers like
"Accept", "User-Agent", etc..

And I check the CGI.pm module too, seems there is no method to get the
unofficial HTTP headers.

If you guys know the HOWTO, pls help me. Thank you!

BTW, English is not my native language, if I have any syntax or grammar
error, pls forgive me:P

Best Regards,
Shu Cao

Wiggins d'Anconia

2005-04-26, 3:55 pm

Shu Cao wrote:
> Hi,
>
> Sorry, my last email has some errors. The unofficial HTTP header should
> look like "x: y" not "x=y".
>
> I am new to Perl CGI programming. And I encounter a difficult problem
> wish you guys can help me. Thank you! Here is the problem, how can Perl
> CGI program get the unofficial HTTP header value like "x: y". I examine
> the %ENV hash, and found nothing but some standard HTTP headers like
> "Accept", "User-Agent", etc..
>
> And I check the CGI.pm module too, seems there is no method to get the
> unofficial HTTP headers.
>


This is going to depend on the web server, as it is the software parsing
the HTTP request, it just passes execution to the CGI and sets up the
environment before hand. So it is up to the web server software to set
in the environment the extra headers, you should check the documentation
for it. It appears that Apache, if you use it, should be passing through
the additional headers with an 'HTTP_' prepended but there is no
guarantee. Docs:

http://hoohoo.ncsa.uiuc.edu/cgi/env.html

"In addition to these, the header lines received from the client, if
any, are placed into the environment with the prefix HTTP_ followed by
the header name. Any - characters in the header name are changed to _
characters. The server may exclude any headers which it has already
processed, such as Authorization, Content-type, and Content-length. If
necessary, the server may choose to exclude any or all of these headers
if including them would exceed any system environment limits."

Which is linked from:

http://httpd.apache.org/docs/howto/...onmentvariables

Which is (obviously) specifically for Apache.

> If you guys know the HOWTO, pls help me. Thank you!
>
> BTW, English is not my native language, if I have any syntax or grammar
> error, pls forgive me:P
>


Thought it was fine.

> Best Regards,
> Shu Cao
>
>


Good luck,

http://danconia.org
Charles K. Clarkson

2005-04-27, 3:55 am

Shu Cao <mailto:sc@netspeed-tech.com> wrote:

: I am new to Perl CGI programming. And I encounter a difficult problem
: wish you guys can help me. Thank you! Here is the problem, how can
: Perl CGI program get the unofficial HTTP header value like "x: y". I
: examine the %ENV hash, and found nothing but some standard HTTP
: headers like "Accept", "User-Agent", etc..

This is the first I have heard there were unofficial HTTP headers
and you have me curious. Why would you want to see these? Are you
writing a low level server script?

TIA,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

Shu Cao

2005-04-27, 3:55 am

Hi, Wiggins d'Anconia:

> This is going to depend on the web server, as it is the software parsing
> the HTTP request, it just passes execution to the CGI and sets up the
> environment before hand. So it is up to the web server software to set
> in the environment the extra headers, you should check the documentation
> for it. It appears that Apache, if you use it, should be passing through
> the additional headers with an 'HTTP_' prepended but there is no
> guarantee. Docs:
>
> http://hoohoo.ncsa.uiuc.edu/cgi/env.html
>
> "In addition to these, the header lines received from the client, if
> any, are placed into the environment with the prefix HTTP_ followed by
> the header name. Any - characters in the header name are changed to _
> characters. The server may exclude any headers which it has already
> processed, such as Authorization, Content-type, and Content-length. If
> necessary, the server may choose to exclude any or all of these headers
> if including them would exceed any system environment limits."
>
> Which is linked from:
>
> http://httpd.apache.org/docs/howto/...onmentvariables
>
> Which is (obviously) specifically for Apache.


Yes, I'm using Apache, and your solution works! Thank you very much!

Best Regards,
Shu Cao
Shu Cao

2005-04-27, 3:55 am

Hi, Charles K. Clarkson:


> This is the first I have heard there were unofficial HTTP headers
> and you have me curious. Why would you want to see these? Are you
> writing a low level server script?



We just use HTTP protocol transferring our customized messages. The
client side is implemented with the libcurl, and we add some unofficial
HTTP headers.

Maybe mod_perl has better control of apache httpd.

Best Regards,
Shu Cao
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com