Home / Class/ Html Class — netty Architecture

Html Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  fe30ffab_b76d_a88a_5dd4_2e3223b0bfc5["Html"]
  ac709d40_7d9e_9b5f_3365_31a00b73d780["Html.java"]
  fe30ffab_b76d_a88a_5dd4_2e3223b0bfc5 -->|defined in| ac709d40_7d9e_9b5f_3365_31a00b73d780
  4a5767fb_b427_ce09_7bfa_5856fbec8a22["Html()"]
  fe30ffab_b76d_a88a_5dd4_2e3223b0bfc5 -->|method| 4a5767fb_b427_ce09_7bfa_5856fbec8a22
  a083340d_7b36_0e07_e5be_8e1d7765fdfa["String()"]
  fe30ffab_b76d_a88a_5dd4_2e3223b0bfc5 -->|method| a083340d_7b36_0e07_e5be_8e1d7765fdfa
  32d6074c_6a40_124d_e04e_0285b04cd357["body()"]
  fe30ffab_b76d_a88a_5dd4_2e3223b0bfc5 -->|method| 32d6074c_6a40_124d_e04e_0285b04cd357
  701c6fc1_0f4f_1076_7d61_d2f4775d15d8["stringLength()"]
  fe30ffab_b76d_a88a_5dd4_2e3223b0bfc5 -->|method| 701c6fc1_0f4f_1076_7d61_d2f4775d15d8

Relationship Graph

Source Code

example/src/main/java/io/netty/example/http2/tiles/Html.java lines 26–79

public final class Html {

    public static final String IP = System.getProperty("ip", "127.0.0.1");

    public static final byte[] FOOTER = "</body></html>".getBytes(UTF_8);

    public static final byte[] HEADER = ("<!DOCTYPE html><html><head lang=\"en\"><title>Netty HTTP/2 Example</title>"
            + "<style>body {background:#DDD;} div#netty { line-height:0;}</style>"
            + "<link rel=\"shortcut icon\" href=\"about:blank\">"
            + "<meta charset=\"UTF-8\"></head><body>A grid of 200 tiled images is shown below. Compare:"
            + "<p>[<a href='https://" + url(Http2Server.PORT) + "?latency=0'>HTTP/2, 0 latency</a>] [<a href='http://"
            + url(HttpServer.PORT) + "?latency=0'>HTTP/1, 0 latency</a>]<br/>" + "[<a href='https://"
            + url(Http2Server.PORT) + "?latency=30'>HTTP/2, 30ms latency</a>] [<a href='http://" + url(HttpServer.PORT)
            + "?latency=30'>HTTP/1, 30ms latency</a>]<br/>" + "[<a href='https://" + url(Http2Server.PORT)
            + "?latency=200'>HTTP/2, 200ms latency</a>] [<a href='http://" + url(HttpServer.PORT)
            + "?latency=200'>HTTP/1, 200ms latency</a>]<br/>" + "[<a href='https://" + url(Http2Server.PORT)
            + "?latency=1000'>HTTP/2, 1s latency</a>] [<a href='http://" + url(HttpServer.PORT)
            + "?latency=1000'>HTTP/1, " + "1s latency</a>]<br/>").getBytes(UTF_8);

    private static final int IMAGES_X_AXIS = 20;

    private static final int IMAGES_Y_AXIS = 10;

    private Html() {
    }

    private static String url(int port) {
        return IP + ":" + port + "/http2";
    }

    public static byte[] body(int latency) {
        int r = Math.abs(new Random().nextInt());
        // The string to be built contains 13192 fixed characters plus the variable latency and random cache-bust.
        int numberOfCharacters = 13192 + stringLength(latency) + stringLength(r);
        StringBuilder sb = new StringBuilder(numberOfCharacters).append("<div id=\"netty\">");
        for (int y = 0; y < IMAGES_Y_AXIS; y++) {
            for (int x = 0; x < IMAGES_X_AXIS; x++) {
                sb.append("<img width=30 height=29 src='/http2?x=")
                .append(x)
                .append("&y=").append(y)
                .append("&cachebust=").append(r)
                .append("&latency=").append(latency)
                .append("'>");
            }
            sb.append("<br/>\r\n");
        }
        sb.append("</div>");
        return sb.toString().getBytes(UTF_8);
    }

    private static int stringLength(int value) {
        return Integer.toString(value).length() * IMAGES_X_AXIS * IMAGES_Y_AXIS;
    }
}

Frequently Asked Questions

What is the Html class?
Html is a class in the netty codebase, defined in example/src/main/java/io/netty/example/http2/tiles/Html.java.
Where is Html defined?
Html is defined in example/src/main/java/io/netty/example/http2/tiles/Html.java at line 26.

Analyze Your Own Codebase

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

Try Supermodel Free