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 Julian Williams <ju...@googlemail.com> on 2007/10/10 13:31:28 UTC

Problem setting new HTTP headers from an input filter

Hi,
I have written an Apache module that controls access depending on
whether a token is present in the request - normally as an HTTP
cookie. I have recently had to modify the module to include an input
filter which will spot the token if included in the body of a POST
request - the SOAP/xml call to a web service. This works OK.

I also need to create some new headers that include user data
extracted from the token. The objective is that the new headers are
easily picked up as server variables in the application environment.
My code uses calls to apr_table_set to create the headers e.g.

	apr_table_set(r->subprocess_env, "HTTP_SAMS_USER", uid);

Whilst this code works fine at the _access_checker stage, it seems to
have no effect at the input filter processing stage and the extra
headers aren't picked up by the cgi application / web service.

Is it just not possible to modify the headers at this point in the
processing 'pipeline' or is there a different way that I can do it?

Many Thanks,

Julian Williams

Re: Problem setting new HTTP headers from an input filter

Posted by Julian Williams <ju...@googlemail.com>.
On 10/10/07, Joe Lewis <jo...@joe-lewis.com> wrote:
> Julian Williams wrote:

[snip]

> > My code uses calls to apr_table_set to create the headers e.g.
> >
> >       apr_table_set(r->subprocess_env, "HTTP_SAMS_USER", uid);
> >
>
> Try :
>
> apr_table_set(r->headers_in, "HTTP_SAMS_USER", uid);
>
>
> in addition to the subprocess_env table set?  (Just in case you aren't
> getting to a subprocess?)
>

Unfortunately that doesn't seem to make any difference. My filter also
sets the REMOTE_USER header (using r->user) which is being logged
correctly in the apache access log. However the web service
application doesn't pick it up which suggests that it's environment is
setup prior to the filter processing. (It is able to see other
standard server variables such as SERVER_NAME)

Thanks,
Julian Williams

Re: Problem setting new HTTP headers from an input filter

Posted by Joe Lewis <jo...@joe-lewis.com>.
Julian Williams wrote:
> Hi,
> I have written an Apache module that controls access depending on
> whether a token is present in the request - normally as an HTTP
> cookie. I have recently had to modify the module to include an input
> filter which will spot the token if included in the body of a POST
> request - the SOAP/xml call to a web service. This works OK.
>
> I also need to create some new headers that include user data
> extracted from the token. The objective is that the new headers are
> easily picked up as server variables in the application environment.
> My code uses calls to apr_table_set to create the headers e.g.
>
> 	apr_table_set(r->subprocess_env, "HTTP_SAMS_USER", uid);
>   

Try :

apr_table_set(r->headers_in, "HTTP_SAMS_USER", uid);


in addition to the subprocess_env table set?  (Just in case you aren't
getting to a subprocess?)

Joe
-- 
Joseph Lewis <http://sharktooth.org/>
"Divide the fire, and you will sooner put it out." - Publius Syrus

Re: Problem setting new HTTP headers from an input filter

Posted by Julian Williams <ju...@googlemail.com>.
On 10/10/07, Arturo 'Buanzo' Busleiman <bu...@buanzo.com.ar> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> Julian Williams wrote:
> > Is it just not possible to modify the headers at this point in the
> > processing 'pipeline' or is there a different way that I can do it?
>
> What TYPE of input filter is it?
>
I'm not sure I know what you mean by TYPE. This is what I have in my
register_hooks function:

ap_hook_insert_filter(sams_soap_insert, NULL, NULL, APR_HOOK_MIDDLE);
ap_register_input_filter(filter_name, sams_soap_filter_in, NULL,
AP_FTYPE_RESOURCE );

So perhaps you mean the type AP_FTYPE_RESOURCE . I have also tried
using AP_FTYPE_CONTENT_SET but I don't think it made any difference.

Thanks,
Julian Williams

Re: Problem setting new HTTP headers from an input filter

Posted by Arturo 'Buanzo' Busleiman <bu...@buanzo.com.ar>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Julian Williams wrote:
> Is it just not possible to modify the headers at this point in the
> processing 'pipeline' or is there a different way that I can do it?

What TYPE of input filter is it?

- --
Arturo "Buanzo" Busleiman - Consultor Independiente en Seguridad Informatica
Servicios Ofrecidos: http://www.buanzo.com.ar/pro/
Unase a los Foros GNU/Buanzo - La palabra Comunidad en su maxima expresion.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHDMU2AlpOsGhXcE0RCrCnAJ9xWReEtX/Rcp8q0bK0wlMiV30PjQCfU0nt
fiYTasO5bdPYrfbrdsBdTh0=
=eNW1
-----END PGP SIGNATURE-----