HttpUtil Class — netty Architecture
Architecture documentation for the HttpUtil class in HttpUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 0b1cc975_2772_c898_b055_3991b4e80dba["HttpUtil"] 562cf7d7_b7c5_0837_2218_5920c048079f["HttpUtil.java"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|defined in| 562cf7d7_b7c5_0837_2218_5920c048079f e3b00711_bb02_26ad_bd61_b7a444b07ab2["HttpUtil()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| e3b00711_bb02_26ad_bd61_b7a444b07ab2 845c445c_6e45_97bb_3c85_1f3374c78816["isOriginForm()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 845c445c_6e45_97bb_3c85_1f3374c78816 801955f5_f118_e804_7680_152e599fc739["isAsteriskForm()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 801955f5_f118_e804_7680_152e599fc739 63f7e0d1_a92d_2eb3_1bd5_d40cf6d00437["validateRequestLineTokens()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 63f7e0d1_a92d_2eb3_1bd5_d40cf6d00437 5cb08eec_4816_55bf_0ac2_3f3587201a37["isEncodingSafeStartLineToken()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 5cb08eec_4816_55bf_0ac2_3f3587201a37 08bc7ef7_c198_c027_e840_3b61e2b0c057["isKeepAlive()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 08bc7ef7_c198_c027_e840_3b61e2b0c057 9dddd038_3680_1ecb_8678_36962ba3edb9["setKeepAlive()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 9dddd038_3680_1ecb_8678_36962ba3edb9 6f9da954_b612_8a2c_b28f_103659ebf676["getContentLength()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 6f9da954_b612_8a2c_b28f_103659ebf676 53f80eda_5c94_cd8f_15bf_80479efefe57["getWebSocketContentLength()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 53f80eda_5c94_cd8f_15bf_80479efefe57 b3c2f9e3_d36d_e896_15c0_d270b621d115["setContentLength()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| b3c2f9e3_d36d_e896_15c0_d270b621d115 472e01ed_d0a0_bfed_06cd_8f9e54ba787e["isContentLengthSet()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 472e01ed_d0a0_bfed_06cd_8f9e54ba787e 704ba4cc_0f40_9cc3_28a4_7a42a168f304["is100ContinueExpected()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 704ba4cc_0f40_9cc3_28a4_7a42a168f304 939d1459_3fa3_a90c_db7e_5c0c70055c60["isUnsupportedExpectation()"] 0b1cc975_2772_c898_b055_3991b4e80dba -->|method| 939d1459_3fa3_a90c_db7e_5c0c70055c60
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java lines 38–818
public final class HttpUtil {
private static final AsciiString CHARSET_EQUALS = AsciiString.of(HttpHeaderValues.CHARSET + "=");
private static final AsciiString SEMICOLON = AsciiString.cached(";");
private static final String COMMA_STRING = String.valueOf(COMMA);
private HttpUtil() { }
/**
* Determine if a uri is in origin-form according to
* <a href="https://datatracker.ietf.org/doc/html/rfc9112#section-3.2.1">RFC 9112, 3.2.1</a>.
*/
public static boolean isOriginForm(URI uri) {
return isOriginForm(uri.toString());
}
/**
* Determine if a string uri is in origin-form according to
* <a href="https://datatracker.ietf.org/doc/html/rfc9112#section-3.2.1">RFC 9112, 3.2.1</a>.
*/
public static boolean isOriginForm(String uri) {
return uri.startsWith("/");
}
/**
* Determine if a uri is in asterisk-form according to
* <a href="https://datatracker.ietf.org/doc/html/rfc9112#section-3.2.4">RFC 9112, 3.2.4</a>.
*/
public static boolean isAsteriskForm(URI uri) {
return isAsteriskForm(uri.toString());
}
/**
* Determine if a string uri is in asterisk-form according to
* <a href="https://datatracker.ietf.org/doc/html/rfc9112#section-3.2.4">RFC 9112, 3.2.4</a>.
*/
public static boolean isAsteriskForm(String uri) {
return "*".equals(uri);
}
static void validateRequestLineTokens(HttpMethod method, String uri) {
// The HttpVersion class does its own validation, and it's not possible for subclasses to circumvent it.
// The HttpMethod class does its own validation, but subclasses might circumvent it.
if (method.getClass() != HttpMethod.class) {
if (!isEncodingSafeStartLineToken(method.asciiName())) {
throw new IllegalArgumentException(
"The HTTP method name contain illegal characters: " + method.asciiName());
}
}
if (!isEncodingSafeStartLineToken(uri)) {
throw new IllegalArgumentException("The URI contain illegal characters: " + uri);
}
}
/**
* Validate that the given request line token is safe for verbatim encoding to the network.
* This does not fully check that the token – HTTP method, version, or URI – is valid and formatted correctly.
* Only that the token does not contain characters that would break or
* desynchronize HTTP message parsing of the start line wherein the token would be included.
* <p>
* See <a href="https://datatracker.ietf.org/doc/html/rfc9112#name-request-line">RFC 9112, 3.</a>
*
* @param token The token to check.
* @return {@code true} if the token is safe to encode verbatim into the HTTP message output stream,
* otherwise {@code false}.
*/
public static boolean isEncodingSafeStartLineToken(CharSequence token) {
int lenBytes = token.length();
for (int i = 0; i < lenBytes; i++) {
char ch = token.charAt(i);
// this is to help AOT compiled code which cannot profile the switch
if (ch <= ' ') {
switch (ch) {
case '\n':
case '\r':
case ' ':
return false;
}
}
}
Source
Frequently Asked Questions
What is the HttpUtil class?
HttpUtil is a class in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java.
Where is HttpUtil defined?
HttpUtil is defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java at line 38.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free