Skip to content

Commit

Permalink
Added check for head and special response decoder for head closes #17
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Fisk committed Mar 4, 2012
1 parent 4dce2c7 commit 4a99219
Showing 1 changed file with 13 additions and 2 deletions.
Expand Up @@ -8,6 +8,7 @@
import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
import org.jboss.netty.handler.codec.http.HttpContentDecompressor;
import org.jboss.netty.handler.codec.http.HttpMessage;
import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponseDecoder;
Expand Down Expand Up @@ -67,8 +68,18 @@ public ChannelPipeline getPipeline() throws Exception {
//
// We also importantly need to follow the cache directives
// in the HTTP response.
pipeline.addLast("decoder",
new HttpResponseDecoder(8192, 8192*2, 8192*2));
final HttpResponseDecoder decoder;
if(httpRequest.getMethod() == HttpMethod.HEAD) {
decoder = new HttpResponseDecoder(8192, 8192*2, 8192*2) {
@Override
protected boolean isContentAlwaysEmpty(final HttpMessage msg) {
return true;
}
};
} else {
decoder = new HttpResponseDecoder(8192, 8192*2, 8192*2);
}
pipeline.addLast("decoder", decoder);

LOG.debug("Querying for host and port: {}", hostAndPort);
final boolean shouldFilter;
Expand Down

0 comments on commit 4a99219

Please sign in to comment.