Hi,
On Tue, Aug 30, 2011 at 5:31 PM, Konstantin Kolinko
<[email protected]>wrote:
>
>
> Attachments are usually dropped by mailing list software. The one you
> mention above is no exception.
>
> > GET / HTTP/1.1
> > Date: Tue, 30 Aug 2011 02:28:50 GMT
> > Content-Type:
> > Authorization: AWS AKIAJHSWPWM6W6KUXAIQ:u4QnOMbP0vuTsgpUXQ0WfXIWz9c=
> > Host: s3.amazonaws.com:80
> > Connection: Keep-Alive
> > User-Agent: Cyberduck/4.1 (8911) (Windows 7/6.1) (x86)
> > Accept-Encoding: gzip,deflate
>
> 1) GET requests cannot have content, and thus having a Content-Type
> header there is confusing.
>
> 2) Content-Type header is defined in section 14.17 of RFC2616 as
>
> Content-Type = "Content-Type" ":" media-type
>
> and
>
> media-type = type "/" subtype *( ";" parameter )
>
> The media-type is not optional and it cannot be empty.
>
Thanks for letting me know and your further explanation!
By the way, my friend has provide me a workaround using filter, post it here
in case some other might need it.
I have tested it locally and it works.
1) CleanHeaderFilter.java
package org.sample;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
public class CleanHeaderFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpReq = new
HttpServletRequestWrapper((HttpServletRequest) request) {
@Override
public Enumeration getHeaderNames() {
if ("GET".equalsIgnoreCase(getMethod())) {
Collection<String> c = new LinkedList<String>();
Enumeration headers = super.getHeaderNames();
while (headers.hasMoreElements()) {
String header = (String) headers.nextElement();
if (!"Content-Type".equalsIgnoreCase(header)) {
c.add(header);
} else {
System.err.println("Remove Content-Type for
GET");
}
}
return Collections.enumeration(c);
}
return super.getHeaderNames();
}
};
chain.doFilter(httpReq, response);
}
@Override
public void destroy() {
}
}
2) add following config to your web.xml
<filter>
<filter-name>cleanHeaderFilter</filter-name>
<filter-class>org.sample.CleanHeaderFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cleanHeaderFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>