httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rudolf Bargholz <bargh...@onlinetravel.ch>
Subject AW: [users@httpd] RequestHeader, SetEnvIf: Setting a missing RequestHeader
Date Fri, 30 Mar 2012 13:55:18 GMT
Le 30/03/2012 14:16, Rudolf Bargholz a écrit :

> Goal: to automatically set the SOAPAction if empty or missing.
>
> Here what I would expect to work, but does not.
>
> <Files "nph-owscgi.exe">
>
> SetEnvIf SOAPAction ^h.*$ HAVE_SOAPAction
>
> RequestHeader set SOAPAction "http://127.0.0.1:5912"
> env=!HAVE_SOAPAction
>
> </Files>
>
> What I am trying to tell Apache is, if the SOAPAction RequestHeader
> starts with an "h", then set the environment variable HAVE_SOAPAction.
> If the environment variable HAVE_SOAPAction is not set, then set the
> SOAPAction ReqeustHeader to the default value of "http://127.0.0.1:5912".
>
> Tried other
>
> Unfortunately this is not working. The SOAPAction is always being
> overwritten, not just if empty or missing from the request headers.
>
> Any tips what I am doing wrong?

Hi Rudolf,

AFAIK, SetEnvIf's first argument is supposed to be a standard header name (listed in RFC2616)
or an environment variable. I'm wondering whether your SOAPAction custom header is really
taken into account as an environment variable. It seems that it's not the case, so maybe you
could try to set an environment variable based on your header, by using a side effect of a
RewriteRule ("E" flag) and then using that variable in your test ?

Here is how I would do that:

RewriteEngine on
RewriteRule .* - [E=SOAPAction:%{HTTP:SOAPAction}]

Then you might be able to use the SOAPAction *environment variable* which will have the same
value as the SOAPAction *HTTP header*



Hi Bruno,

Thanks for taking the time to help.

Turned on mod_rewrite by uncommenting it in the httpd.conf, added " Options +FollowSymlinks"
to my ".htaccess", and then tested the following:

<Files "nph-owscgi.exe">
  RewriteEngine on
  RewriteRule .* - [E=SOAPAction:%{HTTP:SOAPAction}]
  SetEnvIf SOAPAction ^(http) HAVE_SOAPAction
  RequestHeader set SOAPAction "http://127.0.0.1:5912" env=!HAVE_SOAPAction
</Files>

No error returned.

Then tested what would happen if I change the port to an invalid port. If a valid SOAPAction
is supplied, this ought not have any effect on the result. It still ought to work correctly.
The case where the SOAPAction is missing or empty would however report an error. My test determined
that if I changed the conf to

<Files "nph-owscgi.exe">
  RewriteEngine on
  RewriteRule .* - [E=SOAPAction:%{HTTP:SOAPAction}]
  SetEnvIf SOAPAction ^(http) HAVE_SOAPAction
  RequestHeader set SOAPAction "http://127.0.0.1:5912" env=!HAVE_SOAPAction
</Files>

then in both cases the web service returns an error. So even in the case where I have a SOAPAction,
it is being overwritten by the httpd.conf.

So no, this did not work, or I am doing something wrong, which is very likely.

Regards

Rudolf



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message