You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Teppei Yamada <te...@silk.co.jp> on 2012/04/01 11:15:07 UTC

Implementing mod_headers for response in Tomcat7

Hi,


I wanted to write something similar to apache httpd's mod_headers so I
read through Tomcat7.0.26 source code.
Then I realized that that could not be achieved without modifying coyote's
Abstract(Http11|Ajp)Processor.prepareResponse().
That can never be done by Valve because some HTTP headers are added just
in (or SessionCookie is right before) prepareResponse function and it
immediately writes headers to OutputBuffer and set committed.

So I propose inserting some code in prepareResponse.
Is is acceptable?

---
Teppei



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


Re: Implementing mod_headers for response in Tomcat7

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Teppei,

On 4/1/12 5:15 AM, Teppei Yamada wrote:
> I wanted to write something similar to apache httpd's mod_headers
> so I read through Tomcat7.0.26 source code. Then I realized that
> that could not be achieved without modifying coyote's 
> Abstract(Http11|Ajp)Processor.prepareResponse(). That can never be
> done by Valve because some HTTP headers are added just in (or
> SessionCookie is right before) prepareResponse function and it 
> immediately writes headers to OutputBuffer and set committed.

Most headers in Tomcat are added by components other than the
Processor and/or Connector. If you insert a Valve into the valve
chain, you can often intercept and/or re-write the headers at will.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk96DWcACgkQ9CaO5/Lv0PAnlQCglCHz3FTA1Iutre/55T783Sbs
VQEAnR5chWgd7EUT3BoMWHc1r1Vz4kkT
=ocz9
-----END PGP SIGNATURE-----

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


Re: Implementing mod_headers for response in Tomcat7

Posted by Pid <pi...@pidster.com>.
On 01/04/2012 10:15, Teppei Yamada wrote:
> Hi,
> 
> 
> I wanted to write something similar to apache httpd's mod_headers so I
> read through Tomcat7.0.26 source code.
> Then I realized that that could not be achieved without modifying coyote's
> Abstract(Http11|Ajp)Processor.prepareResponse().
> That can never be done by Valve because some HTTP headers are added just
> in (or SessionCookie is right before) prepareResponse function and it
> immediately writes headers to OutputBuffer and set committed.

A Valve would be the way to address this requirement.

> So I propose inserting some code in prepareResponse.
> Is is acceptable?

You can customise Tomcat as you see fit, at your own risk.

Given your other thread regarding secure session cookies, I assume that
your requirement above is derived from a wish to modify the cookie header?


p


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


-- 

[key:62590808]