Search in sources :

Example 1 with Http2FrameType

use of io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameType in project zilla by aklivity.

the class HttpServerFactory method decodeHttp2FrameType.

private int decodeHttp2FrameType(Http2Server server, long traceId, long authorization, long budgetId, DirectBuffer buffer, int offset, int limit) {
    final Http2FrameInfoFW http2FrameInfo = http2FrameInfoRO.tryWrap(buffer, offset, limit);
    if (http2FrameInfo != null) {
        final int length = http2FrameInfo.length();
        final Http2FrameType type = http2FrameInfo.type();
        final Http2ServerDecoder decoder = decodersByFrameType.getOrDefault(type, decodeHttp2IgnoreOne);
        server.decodedStreamId = http2FrameInfo.streamId();
        server.decodedFlags = http2FrameInfo.flags();
        Http2ErrorCode error = Http2ErrorCode.NO_ERROR;
        if (length > server.localSettings.maxFrameSize) {
            error = Http2ErrorCode.FRAME_SIZE_ERROR;
        } else if (decoder == null || server.continuationStreamId != 0 && decoder != decodeHttp2Continuation) {
            error = Http2ErrorCode.PROTOCOL_ERROR;
        }
        if (error != Http2ErrorCode.NO_ERROR) {
            server.onDecodeError(traceId, authorization, error);
            server.decoder = decodeHttp2IgnoreAll;
        } else if (limit - http2FrameInfo.limit() >= length) {
            server.decoder = decoder;
        }
    }
    return offset;
}
Also used : Http2FrameInfoFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW) Http2FrameType(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameType) Http2ErrorCode(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ErrorCode)

Aggregations

Http2ErrorCode (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ErrorCode)1 Http2FrameInfoFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW)1 Http2FrameType (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameType)1