You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Hanks Wang (hanwan)" <ha...@cisco.com> on 2008/02/27 10:22:29 UTC
remove "content-length" item from the http header of HttpServletResponse
Hi all,
All http response generated by tomcat owns a http header item
"content-length".
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
chunked-encoding.
Thanks a lot!
Han
RE: remove "content-length" item from the http header of HttpServletResponse
Posted by "Hanks Wang (hanwan)" <ha...@cisco.com>.
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?
Eg:
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
?
Thanks
Han
-----Original Message-----
From: Leech, Jonathan [mailto:jleech@virtela.net]
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
HttpServletResponse
Create a Filter, map it to the relevant requests, and in your doFilter()
method do something like this:
chain.doFilter(
request,
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) [mailto:hanwan@cisco.com]
Sent: Wednesday, February 27, 2008 2:22 AM
To: dev@tomcat.apache.org
Subject: remove "content-length" item from the http header of
HttpServletResponse
Hi all,
All http response generated by tomcat owns a http header item
"content-length".
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
chunked-encoding.
Thanks a lot!
Han
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
RE: remove "content-length" item from the http header of HttpServletResponse
Posted by "Leech, Jonathan" <jl...@virtela.net>.
Create a Filter, map it to the relevant requests, and in your doFilter()
method do something like this:
chain.doFilter(
request,
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) [mailto:hanwan@cisco.com]
Sent: Wednesday, February 27, 2008 2:22 AM
To: dev@tomcat.apache.org
Subject: remove "content-length" item from the http header of
HttpServletResponse
Hi all,
All http response generated by tomcat owns a http header item
"content-length".
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
chunked-encoding.
Thanks a lot!
Han
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org