ChannelBuffer headerBlock = ChannelBuffers.dynamicBuffer(
ByteOrder.BIG_ENDIAN, 256);
headerBlock.writeShort(numHeaders);
for (String name: names) {
byte[] nameBytes = name.getBytes("UTF-8");
headerBlock.writeShort(nameBytes.length);
headerBlock.writeBytes(nameBytes);
int savedIndex = headerBlock.writerIndex();
int valueLength = 0;
headerBlock.writeShort(valueLength);
for (String value: headerFrame.getHeaders(name)) {