// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_CONNECTION_STREAM_ID = 0;
// 
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static boolean isServerId(int streamId) {
//     // Server initiated streams have even stream identifiers
//     return streamId % 2 == 0;
// }


import static com.twitter.http2.HttpCodecUtil.isServerId;
import java.io.IOException;
import java.net.SocketAddress;
import java.nio.channels.ClosedChannelException;
import java.util.List;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandler;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.util.internal.EmptyArrays;
import static com.twitter.http2.HttpCodecUtil.HTTP_CONNECTION_STREAM_ID;
        ChannelFuture future = sendGoAwayFrame(status);
        future.addListener(ChannelFutureListener.CLOSE);
    }

    // Http/2 Stream Error Handling:
    //
    // Upon a stream error, the endpoint must send a RST_STREAM frame which contains
    // the Stream-ID for the stream where the error occurred and the error status which
    // caused the error.
    //
    // After sending the RST_STREAM, the stream is closed to the sending endpoint.
    //
    // Note: this is only called by the worker thread
    private void issueStreamError(int streamId, HttpErrorCode errorCode) {

        boolean fireMessageReceived = !httpConnection.isRemoteSideClosed(streamId);
        ChannelPromise promise = context.channel().newPromise();
        removeStream(streamId, promise);

        ByteBuf frame = httpFrameEncoder.encodeRstStreamFrame(streamId, errorCode.getCode());
        context.writeAndFlush(frame, promise);
        if (fireMessageReceived) {
            HttpRstStreamFrame httpRstStreamFrame = new DefaultHttpRstStreamFrame(streamId, errorCode);
            context.fireChannelRead(httpRstStreamFrame);
        }
    }

    // Helper functions

    private boolean isRemoteInitiatedId(int id) {
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static final int HTTP_CONNECTION_STREAM_ID = 0;
// 
// Path: src/main/java/com/twitter/http2/HttpCodecUtil.java
// static boolean isServerId(int streamId) {
//     // Server initiated streams have even stream identifiers
//     return streamId % 2 == 0;
// }


// Path: src/main/java/com/twitter/http2/HttpConnectionHandler.java
import static com.twitter.http2.HttpCodecUtil.isServerId;
import java.io.IOException;
import java.net.SocketAddress;
import java.nio.channels.ClosedChannelException;
import java.util.List;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandler;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.util.internal.EmptyArrays;
import static com.twitter.http2.HttpCodecUtil.HTTP_CONNECTION_STREAM_ID;

        ChannelFuture future = sendGoAwayFrame(status);
        future.addListener(ChannelFutureListener.CLOSE);
    }

    // Http/2 Stream Error Handling:
    //
    // Upon a stream error, the endpoint must send a RST_STREAM frame which contains
    // the Stream-ID for the stream where the error occurred and the error status which
    // caused the error.
    //
    // After sending the RST_STREAM, the stream is closed to the sending endpoint.
    //
    // Note: this is only called by the worker thread
    private void issueStreamError(int streamId, HttpErrorCode errorCode) {

        boolean fireMessageReceived = !httpConnection.isRemoteSideClosed(streamId);
        ChannelPromise promise = context.channel().newPromise();
        removeStream(streamId, promise);

        ByteBuf frame = httpFrameEncoder.encodeRstStreamFrame(streamId, errorCode.getCode());
        context.writeAndFlush(frame, promise);
        if (fireMessageReceived) {
            HttpRstStreamFrame httpRstStreamFrame = new DefaultHttpRstStreamFrame(streamId, errorCode);
            context.fireChannelRead(httpRstStreamFrame);
        }
    }

    // Helper functions

    private boolean isRemoteInitiatedId(int id) {
        boolean serverId = isServerId(id);