Home / File/ Http3RequestStreamValidationUtils.java — netty Source File

Http3RequestStreamValidationUtils.java — netty Source File

Architecture documentation for Http3RequestStreamValidationUtils.java, a java file in the netty codebase.

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2021 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.netty.handler.codec.http3;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpHeaderValues;
import io.netty.handler.codec.quic.QuicStreamChannel;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.internal.StringUtil;

import java.util.function.BooleanSupplier;

import static io.netty.handler.codec.http.HttpUtil.normalizeAndGetContentLength;
import static io.netty.handler.codec.http3.Http3ErrorCode.H3_MESSAGE_ERROR;
import static io.netty.handler.codec.http3.Http3FrameValidationUtils.frameTypeUnexpected;

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();
// ... (99 more lines)

Domain

Subdomains

Frequently Asked Questions

What does Http3RequestStreamValidationUtils.java do?
Http3RequestStreamValidationUtils.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Allocators subdomain.
Where is Http3RequestStreamValidationUtils.java in the architecture?
Http3RequestStreamValidationUtils.java is located at codec-http3/src/main/java/io/netty/handler/codec/http3/Http3RequestStreamValidationUtils.java (domain: Buffer, subdomain: Allocators, directory: codec-http3/src/main/java/io/netty/handler/codec/http3).

Analyze Your Own Codebase

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

Try Supermodel Free