SpdyServerHandler Class — netty Architecture
Architecture documentation for the SpdyServerHandler class in SpdyServerHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 279eefab_81d9_4214_e219_57ef97f6b14c["SpdyServerHandler"] 0600fe09_9b4b_3e98_0043_716c3fdbf4cd["SpdyServerHandler.java"] 279eefab_81d9_4214_e219_57ef97f6b14c -->|defined in| 0600fe09_9b4b_3e98_0043_716c3fdbf4cd 3b3fccc3_0d32_27af_7fb2_32bfcef88693["channelRead0()"] 279eefab_81d9_4214_e219_57ef97f6b14c -->|method| 3b3fccc3_0d32_27af_7fb2_32bfcef88693 9abd1842_7e4a_6a6c_251d_262ad99fdf3e["channelReadComplete()"] 279eefab_81d9_4214_e219_57ef97f6b14c -->|method| 9abd1842_7e4a_6a6c_251d_262ad99fdf3e 6844b7fd_4719_943a_8b56_2b60ac37c047["exceptionCaught()"] 279eefab_81d9_4214_e219_57ef97f6b14c -->|method| 6844b7fd_4719_943a_8b56_2b60ac37c047
Relationship Graph
Source Code
example/src/main/java/io/netty/example/spdy/server/SpdyServerHandler.java lines 45–86
public class SpdyServerHandler extends SimpleChannelInboundHandler<Object> {
@Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HttpRequest) {
HttpRequest req = (HttpRequest) msg;
if (is100ContinueExpected(req)) {
ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE, Unpooled.EMPTY_BUFFER));
}
boolean keepAlive = isKeepAlive(req);
ByteBuf content = Unpooled.copiedBuffer("Hello World " + new Date(), CharsetUtil.UTF_8);
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK, content);
response.headers().set(CONTENT_TYPE, "text/plain; charset=UTF-8");
response.headers().setInt(CONTENT_LENGTH, response.content().readableBytes());
if (keepAlive) {
if (req.protocolVersion().equals(HTTP_1_0)) {
response.headers().set(CONNECTION, KEEP_ALIVE);
}
ctx.write(response);
} else {
// Tell the client we're going to close the connection.
response.headers().set(CONNECTION, CLOSE);
ctx.write(response).addListener(ChannelFutureListener.CLOSE);
}
}
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) {
ctx.flush();
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
}
Source
Frequently Asked Questions
What is the SpdyServerHandler class?
SpdyServerHandler is a class in the netty codebase, defined in example/src/main/java/io/netty/example/spdy/server/SpdyServerHandler.java.
Where is SpdyServerHandler defined?
SpdyServerHandler is defined in example/src/main/java/io/netty/example/spdy/server/SpdyServerHandler.java at line 45.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free