[mod_python] Detecting http vs. https

Niklas Aldergren niklas at chimney.se
Fri Sep 17 02:27:48 EDT 2004


On 17 sep 2004, at 01.15, Niklas Aldergren wrote:

> On 17 sep 2004, at 00.59, Nick wrote:
>
>> The HTTPS variable will be set in the environment.
>>
>> Nick
>>
>> Adrian Holovaty wrote:
>>> Hey everybody,
>>> What's the easiest and most reliable way for me to detect if a 
>>> request has come in via https vs. http?
>>> It'd be best if I didn't have to parse any of the request attributes 
>>> manually.
>>> Thanks,
>>> Adrian
>
> In Apache 2, mod_ssl can be made to set all sorts of fancy environment 
> variables,
> like HTTPS, etc. But, seeing as the interpreter is embedded in the 
> actual
> server process I'm guessing this can't actually be set since a new 
> process is
> never created. Try looking at os.environ -- what I find there is the 
> environment
> for the server process.

Or, maybe I should just be looking at the proper place for the 
environment, req.subprocess_env.

if req.subprocess_env['HTTPS'] == 'on':
	...

I'll be shutting up now :)

/Niklas



More information about the Mod_python mailing list