tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hanks Wang (hanwan)" <>
Subject RE: remove "content-length" item from the http header of HttpServletResponse
Date Thu, 28 Feb 2008 15:19:12 GMT
Hi Leech,

Thanks for your reply.

Get to know tomcat will remove the item automatically if I use
chunked-encoding by invoking response.flushBuffer().

I don't know much about the Filter , But could you please tell me
whether I can change the item's order by it?

Originally the header is :
Server: apache
Accept-Range: none

Can I use Filter to change the header item's sequence and modify it to
Accept-Range: no
Server: apache


-----Original Message-----
From: Leech, Jonathan [] 
Sent: Thursday, February 28, 2008 12:54 AM
To: Tomcat Developers List; Hanks Wang (hanwan)
Subject: RE: remove "content-length" item from the http header of

Create a Filter, map it to the relevant requests, and in your doFilter()
method do something like this:
   new HttpServletResponseWrapper(httpres) {
      public void setContentType(String type) {
      public void setHeader(String name, String value) {
         if (!name.equalsIgnoreCase("content-length")) {
            super.setHeader(name, value);
      public void addHeader(java.lang.String name, java.lang.String
value) {
         if (!name.equalsIgnoreCase("content-length")) {
            super.addHeader(name, value);
      public void setIntHeader(java.lang.String name, int value) {
         if (!name.equalsIgnoreCase("content-length")) {
            super.setIntHeader(name, value);
      public void addIntHeader(java.lang.String name, int value) {
         if (!name.equalsIgnoreCase("content-length")) {
            super.addIntHeader(name, value);

-----Original Message-----
From: Hanks Wang (hanwan) []
Sent: Wednesday, February 27, 2008 2:22 AM
Subject: remove "content-length" item from the http header of

Hi all,
All http response generated by tomcat owns a http header item
How can I remove the item from the header of httpServletResponse? 
The reason is generate chunked http response, according the RFC, there
should be no content-length item in http header when response is
Thanks a lot!

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

View raw message