Apache : Setting response headers conditionally

Apache : Setting response headers conditionally

Post by Hars » Tue, 17 Jul 2001 03:56:38



Folks !

I would like to set some response headers condtionally based on the
presence
of a specific request header.

From Apache docs

"Conditionally send MyHeader on the response if and only if header
"MyRequestHeader" is present on the request. This is useful for
constructing headers in response to some client stimulus. Note that
this example requires the services of the mod_setenvif module.
   SetEnvIf MyRequestHeader value HAVE_MyRequestHeader
   Header add MyHeader "%D %t mytext" env=HAVE_MyRequestHeader

If the header "MyRequestHeader: value" is present on the HTTP request,
the response will contain the following header:
   MyHeader: D=3775428 t=991424704447256 mytext
"

I am using apache-2_0_16 (tried with earlier versions too). I cannot
get it to work
as defined in the documents. I get the following error :

Header takes two or three arguments, an action, header and value

on apachect start. Here is the snippet from my logfile :

SetEnvIf MyReqHeader \.* resp_hdr1
Header set Cache-Control "no-cache" env=resp_hdr1

Does this work ? If so, what am I doing wrong ?

Any help would be appreciated.

Tx,

-harsha

 
 
 

Apache : Setting response headers conditionally

Post by Joshua Sliv » Tue, 17 Jul 2001 08:57:49



> I would like to set some response headers condtionally based on the
> presence
> of a specific request header.
[...]
> I am using apache-2_0_16 (tried with earlier versions too). I cannot
> get it to work
> as defined in the documents. I get the following error :
> Header takes two or three arguments, an action, header and value

Sorry, this feature was added after 2.0.16.  You'll have to wait
for the next release of apache 2.0.

--
Joshua Slive

http://slive.ca/

 
 
 

1. Apache 1.2b3 & Location response header

I'm trying to utilize the Location response header.  I'm running Apache
1.23b on a FreeBSD box w/ Netscape 3.0.  I've followed the syntax of a
few CGI FAQ's.  One in particular states...

BEGIN FAQ QUOTE:

Q4.23: Why doesn't:

print "Location: http://host/page.html\n"

work? Why does it only work the first time and get the redirects wrong
later?

A CGI program can only send one Location header. You also cannot send a
MIME content type if you want the
server to perform redirection. For example, this is not valid, though it
may work with some servers:

     #!/usr/local/bin/perl

     .
     .
     .
     print "Content-type: text/plain\n"
     print "Location: http://some.machine/some.doc\n\n"";

END FAQ QUOTE

I created a simple perl CGI script to test out this response header;
however, the server chokes and returns the following error...

BEGIN SERVER ERROR:

Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.


of the time the error occurred, and
anything you might have done that may have caused the error.

END SERVER ERROR

BEGIN MY SIMPLE PERL TEST SCRIPT:

#!/usr/local/bin/perl

print "Location:  lila.east.isi.edu/~moulton/env.html\n";

END MY SIMPLE PERL TEST SCRIPT

I am uncertain if this has to do with the server or with the Netscape
3.0 browser that I'm using.  From the lack of documentation of this
"Location" response header I'm figuring its pretty new.  I've got three
books on CGI development and only one mentions the "Location" response
header (in small detail).

I'm sure this is simply operator error; however, I've seen no concrete
documentation on how to properly use the "Location" response header.  Is
there any documentation on which response headers Apache supports and
how to utilize them?  Anyone know of an exceptionally good CGI FAQ to
boot?

Sincerely,

--
*****************************************************************
** Thomas Moulton                                              **
** ----------------------------------------------------------- **

*****************************************************************

2. GNUMake documentation - where??

3. Howto rewrite HTTP response headers with Apache?

4. RedHat 5.1 Installation to LS-120 Failing

5. Apache 1.3.20: ap_send_http_header() sends Content-Type header when response contains no body

6. Hauppauge WinTV model 401

7. Response Headers on Apache

8. sharing already allocated memory

9. inconsistencies in header responses using Apache 2.0.35 on Windows 2000 and Solaris 8

10. Apache 1.3.x: What headers are added just before response is sent?

11. Help with setting LANG conditionally based on terminal type

12. make: How to set macro variable conditionally at runtime

13. Apache 1.22b6 BUG FIX: Last-Modified header not being set from mod_include.c