Update the example to utilize the new HttpDecompressionHandler

This commit is contained in:
Trustin Lee 2009-10-22 11:28:38 +00:00
parent 11a1e9ae39
commit dabea9dfff
2 changed files with 4 additions and 0 deletions

View File

@ -87,6 +87,7 @@ public class HttpClient {
HttpVersion.HTTP_1_1, HttpMethod.GET, uri.toASCIIString());
request.setHeader(HttpHeaders.Names.HOST, host);
request.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
request.setHeader(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP);
CookieEncoder httpCookieEncoder = new CookieEncoder(false);
httpCookieEncoder.addCookie("my-cookie", "foo");
httpCookieEncoder.addCookie("another-cookie", "bar");

View File

@ -19,6 +19,7 @@ import static org.jboss.netty.channel.Channels.*;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.handler.codec.http.HttpDecompressionHandler;
import org.jboss.netty.handler.codec.http.HttpRequestEncoder;
import org.jboss.netty.handler.codec.http.HttpResponseDecoder;
@ -34,6 +35,8 @@ public class HttpClientPipelineFactory implements ChannelPipelineFactory {
// Create a default pipeline implementation.
ChannelPipeline pipeline = pipeline();
pipeline.addLast("decoder", new HttpResponseDecoder());
// Remove the following line if you don't want automatic content decompression.
pipeline.addLast("inflater", new HttpDecompressionHandler());
// Uncomment the following line if you don't want to handle HttpChunks.
//pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
pipeline.addLast("encoder", new HttpRequestEncoder());