HttpUploadServerHandler Class — netty Architecture
Architecture documentation for the HttpUploadServerHandler class in HttpUploadServerHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 15610e19_8d3a_d230_9604_65cc0397e9e9["HttpUploadServerHandler"] 63fb3399_04ea_86b3_e0ed_1f46ec4c5c5d["HttpUploadServerHandler.java"] 15610e19_8d3a_d230_9604_65cc0397e9e9 -->|defined in| 63fb3399_04ea_86b3_e0ed_1f46ec4c5c5d f9486b79_7d6f_41b0_f367_577b027da919["channelInactive()"] 15610e19_8d3a_d230_9604_65cc0397e9e9 -->|method| f9486b79_7d6f_41b0_f367_577b027da919 98681448_b82b_1b97_25a8_c44670111876["channelRead0()"] 15610e19_8d3a_d230_9604_65cc0397e9e9 -->|method| 98681448_b82b_1b97_25a8_c44670111876 923cd3c6_0e58_e3f0_61cd_79174fab9b80["reset()"] 15610e19_8d3a_d230_9604_65cc0397e9e9 -->|method| 923cd3c6_0e58_e3f0_61cd_79174fab9b80 d050c74a_76ad_11ea_4f73_932ffdd57807["readHttpDataChunkByChunk()"] 15610e19_8d3a_d230_9604_65cc0397e9e9 -->|method| d050c74a_76ad_11ea_4f73_932ffdd57807 95539507_6c78_9bf4_0be2_a7f34f92df2c["writeHttpData()"] 15610e19_8d3a_d230_9604_65cc0397e9e9 -->|method| 95539507_6c78_9bf4_0be2_a7f34f92df2c 249432b1_eedb_b971_9cab_31fe7c2b63bd["writeResponse()"] 15610e19_8d3a_d230_9604_65cc0397e9e9 -->|method| 249432b1_eedb_b971_9cab_31fe7c2b63bd d1e50d33_7f97_e02f_a49f_0d6fd3b1bffa["writeMenu()"] 15610e19_8d3a_d230_9604_65cc0397e9e9 -->|method| d1e50d33_7f97_e02f_a49f_0d6fd3b1bffa 5f4a1861_d118_6ac5_f442_79b69cfaeb0f["exceptionCaught()"] 15610e19_8d3a_d230_9604_65cc0397e9e9 -->|method| 5f4a1861_d118_6ac5_f442_79b69cfaeb0f
Relationship Graph
Source Code
example/src/main/java/io/netty/example/http/upload/HttpUploadServerHandler.java lines 66–453
public class HttpUploadServerHandler extends SimpleChannelInboundHandler<HttpObject> {
private static final Logger logger = Logger.getLogger(HttpUploadServerHandler.class.getName());
private HttpRequest request;
private HttpData partialContent;
private final StringBuilder responseContent = new StringBuilder();
private static final HttpDataFactory factory =
new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE); // Disk if size exceed
private HttpPostRequestDecoder decoder;
static {
DiskFileUpload.deleteOnExitTemporaryFile = true; // should delete file
// on exit (in normal
// exit)
DiskFileUpload.baseDirectory = null; // system temp directory
DiskAttribute.deleteOnExitTemporaryFile = true; // should delete file on
// exit (in normal exit)
DiskAttribute.baseDirectory = null; // system temp directory
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
if (decoder != null) {
decoder.cleanFiles();
}
}
@Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
if (msg instanceof HttpRequest) {
HttpRequest request = this.request = (HttpRequest) msg;
URI uri = new URI(request.uri());
if (!uri.getPath().startsWith("/form")) {
// Write Menu
writeMenu(ctx);
return;
}
responseContent.setLength(0);
responseContent.append("WELCOME TO THE WILD WILD WEB SERVER\r\n");
responseContent.append("===================================\r\n");
responseContent.append("VERSION: " + request.protocolVersion().text() + "\r\n");
responseContent.append("REQUEST_URI: " + request.uri() + "\r\n\r\n");
responseContent.append("\r\n\r\n");
// new getMethod
for (Entry<String, String> entry : request.headers()) {
responseContent.append("HEADER: " + entry.getKey() + '=' + entry.getValue() + "\r\n");
}
responseContent.append("\r\n\r\n");
// new getMethod
Set<Cookie> cookies;
String value = request.headers().get(HttpHeaderNames.COOKIE);
if (value == null) {
cookies = Collections.emptySet();
} else {
cookies = ServerCookieDecoder.STRICT.decode(value);
}
for (Cookie cookie : cookies) {
responseContent.append("COOKIE: " + cookie + "\r\n");
}
responseContent.append("\r\n\r\n");
QueryStringDecoder decoderQuery = new QueryStringDecoder(request.uri());
Map<String, List<String>> uriAttributes = decoderQuery.parameters();
for (Entry<String, List<String>> attr: uriAttributes.entrySet()) {
for (String attrVal: attr.getValue()) {
responseContent.append("URI: " + attr.getKey() + '=' + attrVal + "\r\n");
}
}
responseContent.append("\r\n\r\n");
// if GET Method: should not try to create an HttpPostRequestDecoder
if (HttpMethod.GET.equals(request.method())) {
Source
Frequently Asked Questions
What is the HttpUploadServerHandler class?
HttpUploadServerHandler is a class in the netty codebase, defined in example/src/main/java/io/netty/example/http/upload/HttpUploadServerHandler.java.
Where is HttpUploadServerHandler defined?
HttpUploadServerHandler is defined in example/src/main/java/io/netty/example/http/upload/HttpUploadServerHandler.java at line 66.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free