Home / Class/ HttpResponseClientHandler Class — netty Architecture

HttpResponseClientHandler Class — netty Architecture

Architecture documentation for the HttpResponseClientHandler class in HttpResponseClientHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  87aa9984_48b3_c4f0_3656_aa8dcb7d0830["HttpResponseClientHandler"]
  b5823068_e34b_a247_dbc9_e9c64e0bfefe["HttpResponseClientHandler.java"]
  87aa9984_48b3_c4f0_3656_aa8dcb7d0830 -->|defined in| b5823068_e34b_a247_dbc9_e9c64e0bfefe
  f8e6f22a_1791_68fe_14f7_5f64c6747999["channelRead0()"]
  87aa9984_48b3_c4f0_3656_aa8dcb7d0830 -->|method| f8e6f22a_1791_68fe_14f7_5f64c6747999
  7b28fcc1_00c4_6c36_4055_31d56208a906["exceptionCaught()"]
  87aa9984_48b3_c4f0_3656_aa8dcb7d0830 -->|method| 7b28fcc1_00c4_6c36_4055_31d56208a906
  17833504_f804_ba37_f58a_6143227abbe0["queue()"]
  87aa9984_48b3_c4f0_3656_aa8dcb7d0830 -->|method| 17833504_f804_ba37_f58a_6143227abbe0

Relationship Graph

Source Code

example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java lines 36–87

public class HttpResponseClientHandler extends SimpleChannelInboundHandler<HttpObject> {

    private final BlockingQueue<ChannelFuture> queue = new LinkedBlockingQueue<ChannelFuture>();

    @Override
    public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
        if (msg instanceof HttpResponse) {
            HttpResponse response = (HttpResponse) msg;

            System.out.println("STATUS: " + response.status());
            System.out.println("VERSION: " + response.protocolVersion());
            System.out.println();

            if (!response.headers().isEmpty()) {
                for (CharSequence name : response.headers().names()) {
                    for (CharSequence value : response.headers().getAll(name)) {
                        System.out.println("HEADER: " + name + " = " + value);
                    }
                }
                System.out.println();
            }

            if (HttpUtil.isTransferEncodingChunked(response)) {
                System.out.println("CHUNKED CONTENT {");
            } else {
                System.out.println("CONTENT {");
            }
        }
        if (msg instanceof HttpContent) {
            HttpContent content = (HttpContent) msg;

            System.out.print(content.content().toString(CharsetUtil.UTF_8));
            System.out.flush();

            if (content instanceof LastHttpContent) {
                System.out.println("} END OF CONTENT");
                queue.add(ctx.channel().newSucceededFuture());
            }
        }
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        queue.add(ctx.channel().newFailedFuture(cause));
        cause.printStackTrace();
        ctx.close();
    }

    public BlockingQueue<ChannelFuture> queue() {
        return queue;
    }
}

Frequently Asked Questions

What is the HttpResponseClientHandler class?
HttpResponseClientHandler is a class in the netty codebase, defined in example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java.
Where is HttpResponseClientHandler defined?
HttpResponseClientHandler is defined in example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java at line 36.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free