Home / Type/ HttpStatusClass Type — netty Architecture

HttpStatusClass Type — netty Architecture

Architecture documentation for the HttpStatusClass type/interface in HttpStatusClass.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  668a0fae_6f05_b2a3_524a_afc3f72273a3["HttpStatusClass"]
  8f9653c1_b84b_4b45_bc3b_1e3ac0ca8e05["HttpStatusClass.java"]
  668a0fae_6f05_b2a3_524a_afc3f72273a3 -->|defined in| 8f9653c1_b84b_4b45_bc3b_1e3ac0ca8e05
  style 668a0fae_6f05_b2a3_524a_afc3f72273a3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/HttpStatusClass.java lines 24–126

public enum HttpStatusClass {
    /**
     * The informational class (1xx)
     */
    INFORMATIONAL(100, 200, "Informational"),
    /**
     * The success class (2xx)
     */
    SUCCESS(200, 300, "Success"),
    /**
     * The redirection class (3xx)
     */
    REDIRECTION(300, 400, "Redirection"),
    /**
     * The client error class (4xx)
     */
    CLIENT_ERROR(400, 500, "Client Error"),
    /**
     * The server error class (5xx)
     */
    SERVER_ERROR(500, 600, "Server Error"),
    /**
     * The unknown class
     */
    UNKNOWN(0, 0, "Unknown Status") {
        @Override
        public boolean contains(int code) {
            return code < 100 || code >= 600;
        }
    };

    private static final HttpStatusClass[] statusArray = new HttpStatusClass[6];
    static {
        statusArray[1] = INFORMATIONAL;
        statusArray[2] = SUCCESS;
        statusArray[3] = REDIRECTION;
        statusArray[4] = CLIENT_ERROR;
        statusArray[5] = SERVER_ERROR;
    }

    /**
     * Returns the class of the specified HTTP status code.
     */
    public static HttpStatusClass valueOf(int code) {
        if (UNKNOWN.contains(code)) {
            return UNKNOWN;
        }
        return statusArray[fast_div100(code)];
    }

    /**
     * @param dividend Must >= 0
     * @return dividend/100
     */
    private static int fast_div100(int dividend) {
        return (int) ((dividend * 1374389535L) >> 37);
    }

    /**
     * Returns the class of the specified HTTP status code.
     * @param code Just the numeric portion of the http status code.
     */
    public static HttpStatusClass valueOf(CharSequence code) {
        if (code != null && code.length() == 3) {
            char c0 = code.charAt(0);
            return isDigit(c0) && isDigit(code.charAt(1)) && isDigit(code.charAt(2)) ? valueOf(digit(c0) * 100)
                                                                                     : UNKNOWN;
        }
        return UNKNOWN;
    }

    private static int digit(char c) {
        return c - '0';
    }

    private static boolean isDigit(char c) {
        return c >= '0' && c <= '9';
    }

    private final int min;
    private final int max;

Frequently Asked Questions

What is the HttpStatusClass type?
HttpStatusClass is a type/interface in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpStatusClass.java.
Where is HttpStatusClass defined?
HttpStatusClass is defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpStatusClass.java at line 24.

Analyze Your Own Codebase

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

Try Supermodel Free