Search in sources :

Example 1 with Http2FrameInfoFW

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

the class HttpServerFactory method decodePriority.

private int decodePriority(Http2Server server, long traceId, long authorization, long budgetId, DirectBuffer buffer, int offset, int limit) {
    int progress = offset;
    final Http2FrameInfoFW http2FrameInfo = http2FrameInfoRO.wrap(buffer, offset, limit);
    final int streamId = http2FrameInfo.streamId();
    final int length = http2FrameInfo.length();
    Http2ErrorCode error = Http2ErrorCode.NO_ERROR;
    if (length != 5) {
        error = Http2ErrorCode.FRAME_SIZE_ERROR;
    } else if (streamId == 0) {
        error = Http2ErrorCode.PROTOCOL_ERROR;
    }
    if (error != Http2ErrorCode.NO_ERROR) {
        server.onDecodeError(traceId, authorization, error);
        server.decoder = decodeHttp2IgnoreAll;
    } else {
        final Http2PriorityFW http2Priority = http2PriorityRO.wrap(buffer, offset, limit);
        server.onDecodePriority(traceId, authorization, http2Priority);
        server.decoder = decodeHttp2FrameType;
        progress = http2Priority.limit();
    }
    return progress;
}
Also used : Http2FrameInfoFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW) Http2PriorityFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PriorityFW) Http2ErrorCode(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ErrorCode)

Example 2 with Http2FrameInfoFW

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

the class HttpServerFactory method decodeHttp2Ping.

private int decodeHttp2Ping(Http2Server server, long traceId, long authorization, long budgetId, DirectBuffer buffer, int offset, int limit) {
    int progress = offset;
    final Http2FrameInfoFW http2FrameInfo = http2FrameInfoRO.wrap(buffer, offset, limit);
    final int streamId = http2FrameInfo.streamId();
    final int length = http2FrameInfo.length();
    Http2ErrorCode error = Http2ErrorCode.NO_ERROR;
    if (length != 8) {
        error = Http2ErrorCode.FRAME_SIZE_ERROR;
    } else if (streamId != 0) {
        error = Http2ErrorCode.PROTOCOL_ERROR;
    }
    if (error != Http2ErrorCode.NO_ERROR) {
        server.onDecodeError(traceId, authorization, error);
        server.decoder = decodeHttp2IgnoreAll;
    } else {
        final Http2PingFW http2Ping = http2PingRO.wrap(buffer, offset, limit);
        server.onDecodePing(traceId, authorization, http2Ping);
        server.decoder = decodeHttp2FrameType;
        progress = http2Ping.limit();
    }
    return progress;
}
Also used : Http2FrameInfoFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW) Http2ErrorCode(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ErrorCode) Http2PingFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PingFW)

Example 3 with Http2FrameInfoFW

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

the class HttpServerFactory method decodeHttp2RstStream.

private int decodeHttp2RstStream(Http2Server server, long traceId, long authorization, long budgetId, DirectBuffer buffer, int offset, int limit) {
    int progress = offset;
    final Http2FrameInfoFW http2FrameInfo = http2FrameInfoRO.wrap(buffer, offset, limit);
    final int streamId = http2FrameInfo.streamId();
    final int length = http2FrameInfo.length();
    Http2ErrorCode error = Http2ErrorCode.NO_ERROR;
    if (streamId == 0) {
        error = Http2ErrorCode.PROTOCOL_ERROR;
    }
    if (length != 4) {
        error = Http2ErrorCode.FRAME_SIZE_ERROR;
    }
    if (error != Http2ErrorCode.NO_ERROR) {
        server.onDecodeError(traceId, authorization, error);
        server.decoder = decodeHttp2IgnoreAll;
    } else {
        if (server.applicationHeadersProcessed.size() < config.maxConcurrentApplicationHeaders()) {
            final Http2RstStreamFW http2RstStream = http2RstStreamRO.wrap(buffer, offset, limit);
            server.onDecodeRstStream(traceId, authorization, http2RstStream);
            server.decoder = decodeHttp2FrameType;
            progress = http2RstStream.limit();
        }
    }
    return progress;
}
Also used : Http2FrameInfoFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW) Http2ErrorCode(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ErrorCode) Http2RstStreamFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2RstStreamFW)

Example 4 with Http2FrameInfoFW

use of io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW 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)

Example 5 with Http2FrameInfoFW

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

the class HttpServerFactory method decodeHttp2IgnoreOne.

private int decodeHttp2IgnoreOne(Http2Server server, long traceId, long authorization, long budgetId, DirectBuffer buffer, int offset, int limit) {
    final Http2FrameInfoFW http2FrameInfo = http2FrameInfoRO.wrap(buffer, offset, limit);
    final int progress = http2FrameInfo.limit() + http2FrameInfo.length();
    server.decoder = decodeHttp2FrameType;
    return progress;
}
Also used : Http2FrameInfoFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW)

Aggregations

Http2FrameInfoFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW)6 Http2ErrorCode (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ErrorCode)5 Http2FrameType (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameType)1 Http2PingFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PingFW)1 Http2PriorityFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2PriorityFW)1 Http2RstStreamFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2RstStreamFW)1 Http2WindowUpdateFW (io.aklivity.zilla.runtime.binding.http.internal.codec.Http2WindowUpdateFW)1