Request Headers In a CGI

M

Michael Foord

Is it possible to get at the http request headers in a normal CGI ?

I can't touch the server, so I can't install anything like mod_python.
I've tried googling but the answer seems to be 'no'.

I know I can reconstruct *most* headers from the environment variables
- is this my only option ? I've heard of 'non-parsed headers', but I
don't know how to use them from within a python cgi....

Anyone got any clues, or answers ?

Regards,


Fuzzy

http://www.voidsapce.org.uk/atlantibots/pythonutils.html
 
S

Sam Holden

Is it possible to get at the http request headers in a normal CGI ?

I can't touch the server, so I can't install anything like mod_python.
I've tried googling but the answer seems to be 'no'.

I know I can reconstruct *most* headers from the environment variables
- is this my only option ? I've heard of 'non-parsed headers', but I
don't know how to use them from within a python cgi....

Non-parsed headers are unrelated - they involve the web server not
parsing the CGI response headers but instead sending them directly to
the browser.

What you want can't be done. You can reconstruct most of what you want
via the environment, but not all of it. HTTP Authentication passwords
leap to mind.
 
M

Michael Foord

Sam Holden said:
Non-parsed headers are unrelated - they involve the web server not
parsing the CGI response headers but instead sending them directly to
the browser.

What you want can't be done. You can reconstruct most of what you want
via the environment, but not all of it. HTTP Authentication passwords
leap to mind.

Ok, thanks.
It's a shame because I'm writing a CGI proxy - which means the user
will have to put their username and password into a form for me, I
can't just proxy their request headers........... (not that that was
unproblematic anyway).

Regards,


Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html
 
M

Michael Foord

Sam Holden said:
Non-parsed headers are unrelated - they involve the web server not
parsing the CGI response headers but instead sending them directly to
the browser.

What you want can't be done. You can reconstruct most of what you want
via the environment, but not all of it. HTTP Authentication passwords
leap to mind.

Which means it's impossible to implement basic authentication in
CGI... it has to be done on the server..... (which I can't do)...

Regards,


Fuzzy
http://www.voidspace.org.uk/atlantibots/pythonutils.html
 
J

John J. Lee

Which means it's impossible to implement basic authentication in
CGI... it has to be done on the server..... (which I can't do)...
[...]

If your server is running Apache, and it's configured leniently enough
(perhaps unlikely), there's a mod_rewrite hack that will allow you to
do this, IIRC.


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top