}
@Override
public ByteBuffer generate(ControlFrame frame)
{
SynReplyFrame synReply = (SynReplyFrame)frame;
short version = synReply.getVersion();
ByteBuffer headersBuffer = headersBlockGenerator.generate(version, synReply.getHeaders());
int frameBodyLength = getFrameDataLength(version);
int frameLength = frameBodyLength + headersBuffer.remaining();
if (frameLength > 0xFF_FF_FF)
{
// Too many headers, but unfortunately we have already modified the compression
// context, so we have no other choice than tear down the connection.
throw new SessionException(SessionStatus.PROTOCOL_ERROR, "Too many headers");
}
int totalLength = ControlFrame.HEADER_LENGTH + frameLength;
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, Generator.useDirectBuffers);
BufferUtil.clearToFill(buffer);
generateControlFrameHeader(synReply, frameLength, buffer);
buffer.putInt(synReply.getStreamId() & 0x7F_FF_FF_FF);
writeAdditional(version, buffer);
buffer.put(headersBuffer);
buffer.flip();