tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Custom response header not working because of Content Length
Date Mon, 10 Aug 2009 15:13:13 GMT
Hash: SHA1


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

- -chris
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message