You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by John Zhang <jo...@yahoo.com> on 2007/12/18 03:23:02 UTC

Is there are any way to know if the request is regular (http) or SSL (https) in a module?

I would like to know the request type in my module
(handler/filter), is there any way to know that (HTTP
vs HTTPS)?

Thanks,
John


Re: Is there are any way to know if the request is regular (http) or SSL (https) in a module?

Posted by John Zhang <jo...@yahoo.com>.
--- Graham Dumpleton <gr...@gmail.com>
wrote:

> On 18/12/2007, Sander Temme <sc...@apache.org>
> wrote:
> >
> > On Dec 17, 2007, at 6:36 PM, Eric Covener wrote:
> >
> > >> I would like to know the request type in my
> module
> > >> (handler/filter), is there any way to know that
> (HTTP
> > >> vs HTTPS)?
> > >
> > > apr_table_get(r->subprocess_env, "HTTPS")  might
> be  what you want
> >
> > That gets set in the Fixup hook, relatively late
> in the request
> > processing process.  You could call
> ap_http_scheme(r) to run the
> > request scheme hook, which will return "https" if
> SSL is disabled or
> > optional on the vhost that accepted the request.
> 
> Or better still, use the function registered by the
> ssl module for the purpose:
> 
> #if AP_SERVER_MAJORVERSION_NUMBER >= 2
> APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec
> *));
> static APR_OPTIONAL_FN_TYPE(ssl_is_https)
> *wsgi_is_https = NULL;
> #endif
> 
>    ...
> 
>    if (!wsgi_is_https)
>         wsgi_is_https =
> APR_RETRIEVE_OPTIONAL_FN(ssl_is_https);
> 
>     if (wsgi_is_https &&
> wsgi_is_https(r->connection))
>         apr_table_set(r->subprocess_env, "HTTPS",
> "1");
> 
> Ie., HTTPS is set by the above sort of process, but
> as pointed out
> that is done only in fixup phase, but you can call
> the ssl_is_https()
> function direct if in earlier phase.
> 
Thanks everyone!  All very useful to me!

Re: Is there are any way to know if the request is regular (http) or SSL (https) in a module?

Posted by Graham Dumpleton <gr...@gmail.com>.
On 18/12/2007, Sander Temme <sc...@apache.org> wrote:
>
> On Dec 17, 2007, at 6:36 PM, Eric Covener wrote:
>
> >> I would like to know the request type in my module
> >> (handler/filter), is there any way to know that (HTTP
> >> vs HTTPS)?
> >
> > apr_table_get(r->subprocess_env, "HTTPS")  might be  what you want
>
> That gets set in the Fixup hook, relatively late in the request
> processing process.  You could call ap_http_scheme(r) to run the
> request scheme hook, which will return "https" if SSL is disabled or
> optional on the vhost that accepted the request.

Or better still, use the function registered by the ssl module for the purpose:

#if AP_SERVER_MAJORVERSION_NUMBER >= 2
APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));
static APR_OPTIONAL_FN_TYPE(ssl_is_https) *wsgi_is_https = NULL;
#endif

   ...

   if (!wsgi_is_https)
        wsgi_is_https = APR_RETRIEVE_OPTIONAL_FN(ssl_is_https);

    if (wsgi_is_https && wsgi_is_https(r->connection))
        apr_table_set(r->subprocess_env, "HTTPS", "1");

Ie., HTTPS is set by the above sort of process, but as pointed out
that is done only in fixup phase, but you can call the ssl_is_https()
function direct if in earlier phase.

Graham

Re: Is there are any way to know if the request is regular (http) or SSL (https) in a module?

Posted by Sander Temme <sc...@apache.org>.
On Dec 17, 2007, at 6:36 PM, Eric Covener wrote:

>> I would like to know the request type in my module
>> (handler/filter), is there any way to know that (HTTP
>> vs HTTPS)?
>
> apr_table_get(r->subprocess_env, "HTTPS")  might be  what you want

That gets set in the Fixup hook, relatively late in the request  
processing process.  You could call ap_http_scheme(r) to run the  
request scheme hook, which will return "https" if SSL is disabled or  
optional on the vhost that accepted the request.

S.

-- 
Sander Temme
sctemme@apache.org
PGP FP: 51B4 8727 466A 0BC3 69F4  B7B8 B2BE BC40 1529 24AF




Re: Is there are any way to know if the request is regular (http) or SSL (https) in a module?

Posted by Eric Covener <co...@gmail.com>.
On Dec 17, 2007 9:23 PM, John Zhang <jo...@yahoo.com> wrote:
> I would like to know the request type in my module
> (handler/filter), is there any way to know that (HTTP
> vs HTTPS)?

apr_table_get(r->subprocess_env, "HTTPS")  might be  what you want


-- 
Eric Covener
covener@gmail.com