You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by kh...@oreillyauto.com on 2012/07/26 23:13:00 UTC

[users@httpd] Using info in response headers to create new header

Hello all,

I've been researching mod_headers all day trying to figure out how to do
this... time to ask the group.

I would like to be able to use the information in a Set-Cookie header to
determine if I should set an additional cookie.  For example, if Set-Cookie
"mycookie=abc123-happy" comes through as a response header, I want to
create another Set-Cookie header with just the "happy" portion of the
original Set-Cookie header.

I know mod_headers can edit an existing header, but I need the original
header (Set-Cookie "mycookie") to stay in tact, while I create another
Set-Cookie header before sending it down the wire.

Thanks for any input or ideas.


Kyle Harper

This communication and any attachments are confidential, protected by Communications Privacy Act 18 USCS � 2510, solely for the use of the intended recipient, and may contain legally privileged material. If you are not the intended recipient, please return or destroy it immediately. Thank you.

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


Re: [users@httpd] Using info in response headers to create new header

Posted by Igor Cicimov <ic...@gmail.com>.
On Fri, Jul 27, 2012 at 10:58 AM, Nick Kew <ni...@webthing.com> wrote:

>
> On 27 Jul 2012, at 01:31, Igor Cicimov wrote:
>
> > Try this untested:
> >
> > SetEnvIf Set-Cookie mycookie=abc123-happy HAVE_happy
>
> How is that going to work?  There are no response headers
> at the point where setenvif runs!  The same applies to similar
> pseudo-programmatic approaches such as mod_rewrite.
>
> Header edit could do it, by appending the other header to the
> one it's looking for (look up header equivalence in the HTTP
> spec if you think that's not the same as what you asked for).
> But there's no scripting engine, so what you can do is limited.
> You'd need a script or module to do any more.
>
> --
> Nick Kew
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
Of course you are right. The SetEnvIf runs against the request not the
response. So better try something like mod_perl, mod_cgi etc.

Re: [users@httpd] Using info in response headers to create new header

Posted by Nick Kew <ni...@webthing.com>.
On 27 Jul 2012, at 01:31, Igor Cicimov wrote:

> Try this untested: 
> 
> SetEnvIf Set-Cookie mycookie=abc123-happy HAVE_happy

How is that going to work?  There are no response headers
at the point where setenvif runs!  The same applies to similar
pseudo-programmatic approaches such as mod_rewrite.

Header edit could do it, by appending the other header to the
one it's looking for (look up header equivalence in the HTTP
spec if you think that's not the same as what you asked for).
But there's no scripting engine, so what you can do is limited.
You'd need a script or module to do any more.

-- 
Nick Kew

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


Re: [users@httpd] Using info in response headers to create new header

Posted by Igor Cicimov <ic...@gmail.com>.
On Fri, Jul 27, 2012 at 7:13 AM, <kh...@oreillyauto.com> wrote:

>
> Hello all,
>
> I've been researching mod_headers all day trying to figure out how to do
> this... time to ask the group.
>
> I would like to be able to use the information in a Set-Cookie header to
> determine if I should set an additional cookie.  For example, if Set-Cookie
> "mycookie=abc123-happy" comes through as a response header, I want to
> create another Set-Cookie header with just the "happy" portion of the
> original Set-Cookie header.
>
> I know mod_headers can edit an existing header, but I need the original
> header (Set-Cookie "mycookie") to stay in tact, while I create another
> Set-Cookie header before sending it down the wire.
>
> Thanks for any input or ideas.
>
>
> Kyle Harper
>
> This communication and any attachments are confidential, protected by
> Communications Privacy Act 18 USCS § 2510, solely for the use of the
> intended recipient, and may contain legally privileged material. If you are
> not the intended recipient, please return or destroy it immediately. Thank
> you.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Try this untested:

SetEnvIf Set-Cookie mycookie=abc123-happy HAVE_happy
Header add Set-Cookie "mycookie2=happy" env=HAVE_happy

This is if the value of the cookie is static (always the same). I'm not
sure how is this going to work in case you need dynamic one which will need
use of regular expression. Then you can't set the variable to a value of
the regular expression which means you will need to use CGI approach.