// Configure the client.
    EventLoopGroup group = new NioEventLoopGroup();
    try {
        Bootstrap b = new Bootstrap();
        //b.group(group)
        //        .channel(NioSocketChannel.class)
        //        .handler(new HttpSnoopClientInitializer(sslCtx));
        //
        //// Make the connection attempt.
        //Channel ch = b.connect(host, port).sync().channel();

        b.group(group).channel(NioSocketChannel.class).handler(new 
HttpSnoopClientInitializer(sslCtx)).remoteAddress(host, port);
        CountingChannelPoolHandler handler = new CountingChannelPoolHandler
(); // CountingChannelPoolHandler is copied from netty test!
        SimpleChannelPool pool = new SimpleChannelPool(b, handler);
        Channel ch = pool.acquire().sync().getNow();

        // Prepare the HTTP request.
        HttpRequest request = new DefaultFullHttpRequest(
                HttpVersion.HTTP_1_1, HttpMethod.GET, uri.getRawPath());
        request.headers().set(HttpHeaderNames.HOST, host);
        request.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.
CLOSE);
        request.headers().set(HttpHeaderNames.ACCEPT_ENCODING, 
HttpHeaderValues.GZIP);

        // Set some example cookies.
        request.headers().set(
                HttpHeaderNames.COOKIE,
                ClientCookieEncoder.STRICT.encode(
                        new DefaultCookie("my-cookie", "foo"),
                        new DefaultCookie("another-cookie", "bar")));

        // Send the HTTP request.
        ch.writeAndFlush(request);

        // Wait for the server to close the connection.
        ch.closeFuture().sync();
    } finally {
        // Shut down executor threads to exit.
        group.shutdownGracefully();
    }

I have posted this question on SO, but few of them get reply, so I post my 
question here.
I use the snoop client of netty example in netty source code for testing.
I make some changes to the HttpSnoopClient class to get channel from 
channel pool instead of getting it from Bootstrap, But that doesn't work 
for me.
I have searched solution for one day, but I can still not get one. Please 
tell me If you have any idea.


-- 
You received this message because you are subscribed to the Google Groups 
"Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/netty/80fae616-a29b-49d8-b5d1-f4a20bb6e7ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to