tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Custom response header not working because of Content Length
Date Mon, 10 Aug 2009 15:13:13 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Anantha,

On 8/10/2009 11:05 AM, Anantha Padmanabha wrote:
> I'm using tomcat 6.0.18. I added a filter that adds a custom response header
> by doing setIntHeader/addIntHeader, but it didnt work.

Do you get an error, or is your header just ignored?

> I debugged,looked at source and figured out that the place where its not
> working.
> Before adding headers, there is a check like this:
> 
> public boolean isAppCommitted() {
>         return (this.appCommitted || isCommitted() || isSuspended()
>                 || ((getContentLength() > 0)
>                     && (getContentCount() >= getContentLength())));
>     }
> 
> Since contentCount [output buffer] and contentLength [Content-Length
> response header] are equal in my case, its not adding that header.

Are you sure it's not because the response has already been committed?
That's the usual problem. Are you attempting to add your header before
or after the response body is generated?

> When there is no content-length in response [ex: status code 304], my custom
> header is coming out nicely.

Note that a 304 response usually does not have much in the way of a
response body, and so the response may not have been committed.

> Is there a way to not use fixed content lengths or should I add calculate
> and change content length while adding custom header?

I think you need to set your header earlier in the request/response time
line.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqAOQkACgkQ9CaO5/Lv0PAZ9wCfeMHKM5VXlR/m3vnUXyWZMVdj
NpgAoI4Hp2X/uVbOZrelgYGIhKN5Q4Hd
=a8EV
-----END PGP SIGNATURE-----

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


Mime
View raw message