package org.glassfish.grizzly.http2;
import org.glassfish.grizzly.Buffer;
import org.glassfish.grizzly.http2.hpack.Encoder;
import org.glassfish.grizzly.memory.CompositeBuffer;
import org.glassfish.grizzly.memory.MemoryManager;
import java.util.Map;
public class {
private static final String =
"org.glassfish.grizzly.http2.HeadersEncoder.DEFAULT_BUFFER_SIZE";
private static final String = "8192";
private static final int =
Integer.parseInt(System.getProperty(DEFAULT_BUFFER_SIZE_PROP_NAME, DEFAULT_BUFFER_SIZE_STRING));
private final Encoder ;
private final MemoryManager ;
private CompositeBuffer ;
public (final MemoryManager memoryManager,
final int maxHeaderTableSize) {
this.memoryManager = memoryManager;
hpackEncoder = new Encoder(maxHeaderTableSize);
}
public void (final String name, final String value, final Map<String,String> capture) {
if (capture != null) {
capture.put(name, value);
}
init();
hpackEncoder.header(name, value);
while (!hpackEncoder.encode(buffer)) {
buffer.append(memoryManager.allocate(DEFAULT_BUFFER_SIZE));
}
}
public Buffer () {
final Buffer bufferLocal = buffer;
bufferLocal.trim();
buffer = null;
return bufferLocal;
}
private void () {
if (buffer == null) {
buffer = CompositeBuffer.newBuffer(memoryManager);
buffer.allowInternalBuffersDispose(true);
buffer.allowBufferDispose(true);
buffer.append(memoryManager.allocate(DEFAULT_BUFFER_SIZE));
}
}
}