Search in sources :

Example 1 with Http2WindowUpdateFW

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

the class HttpServerFactory method decodeHttp2WindowUpdate.

private int decodeHttp2WindowUpdate(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 length = http2FrameInfo.length();
    Http2ErrorCode error = Http2ErrorCode.NO_ERROR;
    if (length != 4) {
        error = Http2ErrorCode.FRAME_SIZE_ERROR;
    }
    if (error == Http2ErrorCode.NO_ERROR) {
        final Http2WindowUpdateFW http2WindowUpdate = http2WindowUpdateRO.wrap(buffer, offset, limit);
        final int streamId = http2WindowUpdate.streamId();
        final int size = http2WindowUpdate.size();
        if (streamId == 0) {
            if (server.remoteSharedBudget + size > Integer.MAX_VALUE) {
                error = Http2ErrorCode.FLOW_CONTROL_ERROR;
            }
        } else {
            if (streamId > server.maxClientStreamId || size < 1) {
                error = Http2ErrorCode.PROTOCOL_ERROR;
            }
        }
        if (error == Http2ErrorCode.NO_ERROR) {
            server.onDecodeWindowUpdate(traceId, authorization, http2WindowUpdate);
            server.decoder = decodeHttp2FrameType;
            progress = http2WindowUpdate.limit();
        }
    }
    if (error != Http2ErrorCode.NO_ERROR) {
        server.onDecodeError(traceId, authorization, error);
        server.decoder = decodeHttp2IgnoreAll;
    }
    return progress;
}
Also used : Http2FrameInfoFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2FrameInfoFW) Http2ErrorCode(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2ErrorCode) Http2WindowUpdateFW(io.aklivity.zilla.runtime.binding.http.internal.codec.Http2WindowUpdateFW)

Aggregations

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