Http3RequestStreamValidationUtils Class — netty Architecture
Architecture documentation for the Http3RequestStreamValidationUtils class in Http3RequestStreamValidationUtils.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 61b512bc_7ad6_0004_be8c_64e50c687fe4["Http3RequestStreamValidationUtils"] a53be3aa_32ce_f122_b199_7e3d273f7a21["Http3RequestStreamValidationUtils.java"] 61b512bc_7ad6_0004_be8c_64e50c687fe4 -->|defined in| a53be3aa_32ce_f122_b199_7e3d273f7a21 45d7d10f_f047_7ac9_df50_c58bcc1cc569["Http3RequestStreamValidationUtils()"] 61b512bc_7ad6_0004_be8c_64e50c687fe4 -->|method| 45d7d10f_f047_7ac9_df50_c58bcc1cc569 c2ce4744_7c3b_b83c_f157_bfa4a5cb5833["validateClientWrite()"] 61b512bc_7ad6_0004_be8c_64e50c687fe4 -->|method| c2ce4744_7c3b_b83c_f157_bfa4a5cb5833 3eaadb49_498a_56f2_789a_a3ac7484e3ba["validateHeaderFrameRead()"] 61b512bc_7ad6_0004_be8c_64e50c687fe4 -->|method| 3eaadb49_498a_56f2_789a_a3ac7484e3ba b1365829_7e75_f2dd_79f7_f9bb91ae2db3["validateDataFrameRead()"] 61b512bc_7ad6_0004_be8c_64e50c687fe4 -->|method| b1365829_7e75_f2dd_79f7_f9bb91ae2db3 7e5ce038_7a9d_00fc_047f_e9bc9d79650d["validateOnStreamClosure()"] 61b512bc_7ad6_0004_be8c_64e50c687fe4 -->|method| 7e5ce038_7a9d_00fc_047f_e9bc9d79650d 1c7f9c1d_607e_cff7_62a2_7d131006f0ee["sendStreamAbandonedIfRequired()"] 61b512bc_7ad6_0004_be8c_64e50c687fe4 -->|method| 1c7f9c1d_607e_cff7_62a2_7d131006f0ee 09a5f632_93f7_38e3_c250_92f4df323485["headerUnexpected()"] 61b512bc_7ad6_0004_be8c_64e50c687fe4 -->|method| 09a5f632_93f7_38e3_c250_92f4df323485 2edc3c59_0b96_9724_4e2d_264ee679fda7["failStream()"] 61b512bc_7ad6_0004_be8c_64e50c687fe4 -->|method| 2edc3c59_0b96_9724_4e2d_264ee679fda7 795a9638_e016_deb7_d77c_ea1d7ae4c93c["verifyContentLength()"] 61b512bc_7ad6_0004_be8c_64e50c687fe4 -->|method| 795a9638_e016_deb7_d77c_ea1d7ae4c93c
Relationship Graph
Source Code
codec-http3/src/main/java/io/netty/handler/codec/http3/Http3RequestStreamValidationUtils.java lines 33–158
final class Http3RequestStreamValidationUtils {
static final long CONTENT_LENGTH_NOT_MODIFIED = -1;
static final long INVALID_FRAME_READ = -2;
private Http3RequestStreamValidationUtils() {
// No instances
}
/**
* Validate write of the passed {@link Http3RequestStreamFrame} for a client and takes appropriate error handling
* for invalid frames.
*
* @param frame to validate.
* @param promise for the write.
* @param ctx for the handler.
* @param goAwayReceivedSupplier for the channel.
* @param encodeState for the stream.
* @return {@code true} if the frame is valid.
*/
static boolean validateClientWrite(Http3RequestStreamFrame frame, ChannelPromise promise, ChannelHandlerContext ctx,
BooleanSupplier goAwayReceivedSupplier,
Http3RequestStreamCodecState encodeState) {
if (goAwayReceivedSupplier.getAsBoolean() && !encodeState.started()) {
String type = StringUtil.simpleClassName(frame);
ReferenceCountUtil.release(frame);
promise.setFailure(new Http3Exception(Http3ErrorCode.H3_FRAME_UNEXPECTED,
"Frame of type " + type + " unexpected as we received a GOAWAY already."));
ctx.close();
return false;
}
if (frame instanceof Http3PushPromiseFrame) {
// Only supported on the server.
// See https://tools.ietf.org/html/draft-ietf-quic-http-32#section-4.1
frameTypeUnexpected(promise, frame);
return false;
}
return true;
}
static long validateHeaderFrameRead(Http3HeadersFrame headersFrame, ChannelHandlerContext ctx,
Http3RequestStreamCodecState decodeState) {
if (headersFrame.headers().contains(HttpHeaderNames.CONNECTION)) {
headerUnexpected(ctx, headersFrame, "connection header included");
return INVALID_FRAME_READ;
}
CharSequence value = headersFrame.headers().get(HttpHeaderNames.TE);
if (value != null && !HttpHeaderValues.TRAILERS.equals(value)) {
headerUnexpected(ctx, headersFrame, "te header field included with invalid value: " + value);
return INVALID_FRAME_READ;
}
if (decodeState.receivedFinalHeaders()) {
long length = normalizeAndGetContentLength(
headersFrame.headers().getAll(HttpHeaderNames.CONTENT_LENGTH), false, true);
if (length != CONTENT_LENGTH_NOT_MODIFIED) {
headersFrame.headers().setLong(HttpHeaderNames.CONTENT_LENGTH, length);
}
return length;
}
return CONTENT_LENGTH_NOT_MODIFIED;
}
static long validateDataFrameRead(Http3DataFrame dataFrame, ChannelHandlerContext ctx,
long expectedLength, long seenLength, boolean clientHeadRequest) {
try {
return verifyContentLength(dataFrame.content().readableBytes(), expectedLength, seenLength, false,
clientHeadRequest);
} catch (Http3Exception e) {
ReferenceCountUtil.release(dataFrame);
failStream(ctx, e);
return INVALID_FRAME_READ;
}
}
static boolean validateOnStreamClosure(ChannelHandlerContext ctx, long expectedLength, long seenLength,
boolean clientHeadRequest) {
try {
verifyContentLength(0, expectedLength, seenLength, true, clientHeadRequest);
return true;
} catch (Http3Exception e) {
ctx.fireExceptionCaught(e);
Http3CodecUtils.streamError(ctx, e.errorCode());
Defined In
Source
Frequently Asked Questions
What is the Http3RequestStreamValidationUtils class?
Http3RequestStreamValidationUtils is a class in the netty codebase, defined in codec-http3/src/main/java/io/netty/handler/codec/http3/Http3RequestStreamValidationUtils.java.
Where is Http3RequestStreamValidationUtils defined?
Http3RequestStreamValidationUtils is defined in codec-http3/src/main/java/io/netty/handler/codec/http3/Http3RequestStreamValidationUtils.java at line 33.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free