Implemented handling of SETTINGS_HEADER_TABLE_SIZE configuration property.

This commit is contained in:
Simone Bordet 2014-08-01 16:20:20 +02:00
parent 346b726c47
commit cddfa033f0
2 changed files with 15 additions and 8 deletions

View File

@ -176,7 +176,13 @@ public abstract class HTTP2Session implements ISession, Parser.Listener
return false;
Map<Integer, Integer> settings = frame.getSettings();
// TODO: handle other settings
if (settings.containsKey(SettingsFrame.HEADER_TABLE_SIZE))
{
int headerTableSize = settings.get(SettingsFrame.HEADER_TABLE_SIZE);
if (LOG.isDebugEnabled())
LOG.debug("Updated HPACK header table size to {}", headerTableSize);
generator.setHeaderTableSize(headerTableSize);
}
if (settings.containsKey(SettingsFrame.MAX_CONCURRENT_STREAMS))
{
maxStreamCount = settings.get(SettingsFrame.MAX_CONCURRENT_STREAMS);
@ -197,6 +203,8 @@ public abstract class HTTP2Session implements ISession, Parser.Listener
onConnectionFailure(ErrorCodes.PROTOCOL_ERROR, "invalid_settings_max_frame_size");
return false;
}
if (LOG.isDebugEnabled())
LOG.debug("Updated max frame size to {}", maxFrameSize);
generator.setMaxFrameSize(maxFrameSize);
}
notifySettings(this, frame);

View File

@ -27,8 +27,8 @@ import org.eclipse.jetty.io.ByteBufferPool;
public class Generator
{
private final ByteBufferPool byteBufferPool;
private final int headerTableSize;
private final HeaderGenerator headerGenerator;
private final HpackEncoder hpackEncoder;
private final FrameGenerator[] generators;
private final DataGenerator dataGenerator;
@ -40,17 +40,16 @@ public class Generator
public Generator(ByteBufferPool byteBufferPool, int headerTableSize)
{
this.byteBufferPool = byteBufferPool;
this.headerTableSize = headerTableSize;
headerGenerator = new HeaderGenerator();
HpackEncoder encoder = new HpackEncoder(headerTableSize);
hpackEncoder = new HpackEncoder(headerTableSize);
this.generators = new FrameGenerator[FrameType.values().length];
this.generators[FrameType.HEADERS.getType()] = new HeadersGenerator(headerGenerator, encoder);
this.generators[FrameType.HEADERS.getType()] = new HeadersGenerator(headerGenerator, hpackEncoder);
this.generators[FrameType.PRIORITY.getType()] = new PriorityGenerator(headerGenerator);
this.generators[FrameType.RST_STREAM.getType()] = new ResetGenerator(headerGenerator);
this.generators[FrameType.SETTINGS.getType()] = new SettingsGenerator(headerGenerator);
this.generators[FrameType.PUSH_PROMISE.getType()] = new PushPromiseGenerator(headerGenerator, encoder);
this.generators[FrameType.PUSH_PROMISE.getType()] = new PushPromiseGenerator(headerGenerator, hpackEncoder);
this.generators[FrameType.PING.getType()] = new PingGenerator(headerGenerator);
this.generators[FrameType.GO_AWAY.getType()] = new GoAwayGenerator(headerGenerator);
this.generators[FrameType.WINDOW_UPDATE.getType()] = new WindowUpdateGenerator(headerGenerator);
@ -64,9 +63,9 @@ public class Generator
return byteBufferPool;
}
public int getHeaderTableSize()
public void setHeaderTableSize(int headerTableSize)
{
return headerTableSize;
hpackEncoder.setRemoteMaxHeaderTableSize(headerTableSize);
}
public void setMaxFrameSize(int maxFrameSize)