From c3472f01c424c251d14fa5791b945a5b38356f10 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 4 Dec 2014 10:27:14 +0100 Subject: [PATCH] updated hpack for draft 10 name changes --- .../jetty/http2/generator/Generator.java | 2 +- .../eclipse/jetty/http2/parser/Parser.java | 4 ++-- .../jetty/http2/parser/ServerParser.java | 4 ++-- .../jetty/http2/hpack/HpackContext.java | 8 +++---- .../jetty/http2/hpack/HpackDecoder.java | 2 +- .../jetty/http2/hpack/HpackEncoder.java | 22 +++++++++---------- .../jetty/http2/hpack/HpackContextTest.java | 2 +- .../jetty/http2/hpack/HpackEncoderTest.java | 16 +++++++------- .../jetty/http2/hpack/HpackPerfTest.java | 10 ++++----- .../AbstractHTTP2ServerConnectionFactory.java | 10 ++++----- .../server/HTTP2ServerConnectionFactory.java | 4 ++-- .../RawHTTP2ServerConnectionFactory.java | 2 +- 12 files changed, 43 insertions(+), 43 deletions(-) diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java index 0b5f8ff16f6..70b7bb5df56 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java @@ -67,7 +67,7 @@ public class Generator public void setHeaderTableSize(int headerTableSize) { - hpackEncoder.setRemoteMaxHeaderTableSize(headerTableSize); + hpackEncoder.setRemoteMaxDynamicTableSize(headerTableSize); } public void setMaxFrameSize(int maxFrameSize) diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/Parser.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/Parser.java index 09689b32aeb..7220d2aaf87 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/Parser.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/Parser.java @@ -45,13 +45,13 @@ public class Parser private final BodyParser[] bodyParsers; private State state = State.HEADER; - public Parser(ByteBufferPool byteBufferPool, Listener listener, int maxHeaderTableSize, int maxHeaderSize) + public Parser(ByteBufferPool byteBufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize) { this.listener = listener; this.headerParser = new HeaderParser(); this.bodyParsers = new BodyParser[FrameType.values().length]; - HeaderBlockParser headerBlockParser = new HeaderBlockParser(byteBufferPool, new HpackDecoder(maxHeaderTableSize, maxHeaderSize)); + HeaderBlockParser headerBlockParser = new HeaderBlockParser(byteBufferPool, new HpackDecoder(maxDynamicTableSize, maxHeaderSize)); bodyParsers[FrameType.DATA.getType()] = new DataBodyParser(headerParser, listener); bodyParsers[FrameType.HEADERS.getType()] = new HeadersBodyParser(headerParser, listener, headerBlockParser); diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/ServerParser.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/ServerParser.java index 44f523925b2..32e2e692a5c 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/ServerParser.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/parser/ServerParser.java @@ -33,9 +33,9 @@ public class ServerParser extends Parser private final PrefaceParser prefaceParser; private State state = State.PREFACE; - public ServerParser(ByteBufferPool byteBufferPool, Listener listener, int maxHeaderTableSize, int maxHeaderSize) + public ServerParser(ByteBufferPool byteBufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize) { - super(byteBufferPool, listener, maxHeaderTableSize, maxHeaderSize); + super(byteBufferPool, listener, maxDynamicTableSize, maxHeaderSize); this.listener = listener; this.prefaceParser = new PrefaceParser(listener); } diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java index 19701f02553..227d9f32b28 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java @@ -267,7 +267,7 @@ public class HpackContext } /** - * @return Current Header table size in entries + * @return Current dynamic table size in entries */ public int size() { @@ -275,15 +275,15 @@ public class HpackContext } /** - * @return Current Header table size in Octets + * @return Current Dynamic table size in Octets */ - public int getHeaderTableSize() + public int getDynamicTableSize() { return _dynamicTableSizeInBytes; } /** - * @return Max Header table size in Octets + * @return Max Dynamic table size in Octets */ public int getMaxDynamicTableSize() { diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackDecoder.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackDecoder.java index 63214fefba3..89d95666a08 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackDecoder.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackDecoder.java @@ -232,7 +232,7 @@ public class HpackDecoder // if indexed if (indexed) { - // add to header table + // add to dynamic table _context.add(field); } diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java index 4dc868d6390..0c1406d5b53 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java @@ -95,16 +95,16 @@ public class HpackEncoder this(4096,4096); } - public HpackEncoder(int localMaxHeaderTableSize) + public HpackEncoder(int localMaxDynamicTableSize) { - this(localMaxHeaderTableSize,4096); + this(localMaxDynamicTableSize,4096); } - public HpackEncoder(int localMaxHeaderTableSize,int remoteMaxHeaderTableSize) + public HpackEncoder(int localMaxDynamicTableSize,int remoteMaxDynamicTableSize) { - _context=new HpackContext(remoteMaxHeaderTableSize); - _remoteMaxDynamicTableSize=remoteMaxHeaderTableSize; - _localMaxDynamicTableSize=localMaxHeaderTableSize; + _context=new HpackContext(remoteMaxDynamicTableSize); + _remoteMaxDynamicTableSize=remoteMaxDynamicTableSize; + _localMaxDynamicTableSize=localMaxDynamicTableSize; _debug=LOG.isDebugEnabled(); } @@ -113,14 +113,14 @@ public class HpackEncoder return _context; } - public void setRemoteMaxHeaderTableSize(int remoteMaxHeaderTableSize) + public void setRemoteMaxDynamicTableSize(int remoteMaxDynamicTableSize) { - _remoteMaxDynamicTableSize=remoteMaxHeaderTableSize; + _remoteMaxDynamicTableSize=remoteMaxDynamicTableSize; } - public void setLocalMaxHeaderTableSize(int localMaxHeaderTableSize) + public void setLocalMaxDynamicTableSize(int localMaxDynamicTableSize) { - _localMaxDynamicTableSize=localMaxHeaderTableSize; + _localMaxDynamicTableSize=localMaxDynamicTableSize; } // TODO better handling of buffer size @@ -140,7 +140,7 @@ public class HpackEncoder int pos = buffer.position(); - // Check the header table sizes! + // Check the dynamic table sizes! int maxDynamicTableSize=Math.min(_remoteMaxDynamicTableSize,_localMaxDynamicTableSize); if (maxDynamicTableSize!=_context.getMaxDynamicTableSize()) encodeMaxDynamicTableSize(buffer,maxDynamicTableSize); diff --git a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackContextTest.java b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackContextTest.java index 120fc199e6e..c0332a79496 100644 --- a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackContextTest.java +++ b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackContextTest.java @@ -140,7 +140,7 @@ public class HpackContextTest assertEquals(methodGet,ctx.get(methodGet).getHttpField()); assertTrue(ctx.get(methodGet).isStatic()); - // Add static version to header table + // Add static version to dynamic table Entry e0=ctx.add(ctx.get(methodGet).getHttpField()); // Look again and should see dynamic version diff --git a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackEncoderTest.java b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackEncoderTest.java index d3b4f883996..80ae54f53bb 100644 --- a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackEncoderTest.java +++ b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackEncoderTest.java @@ -74,7 +74,7 @@ public class HpackEncoderTest // something was encoded! assertThat(buffer.remaining(),Matchers.greaterThan(0)); - // All are in the header table + // All are in the dynamic table Assert.assertEquals(4,encoder.getContext().size()); // encode exact same fields again! @@ -82,7 +82,7 @@ public class HpackEncoderTest encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields)); BufferUtil.flipToFlush(buffer,0); - // All are in the header table + // All are in the dynamic table Assert.assertEquals(4,encoder.getContext().size()); // Add 4 more fields @@ -97,7 +97,7 @@ public class HpackEncoderTest // something was encoded! assertThat(buffer.remaining(),Matchers.greaterThan(0)); - // max header table size reached + // max dynamic table size reached Assert.assertEquals(5,encoder.getContext().size()); @@ -113,7 +113,7 @@ public class HpackEncoderTest // something was encoded! assertThat(buffer.remaining(),Matchers.greaterThan(0)); - // max header table size reached + // max dynamic table size reached Assert.assertEquals(5,encoder.getContext().size()); @@ -128,7 +128,7 @@ public class HpackEncoderTest // something was encoded! assertThat(buffer.remaining(),Matchers.greaterThan(0)); - // max header table size reached + // max dynamic table size reached Assert.assertEquals(5,encoder.getContext().size()); @@ -144,7 +144,7 @@ public class HpackEncoderTest // something was encoded! assertThat(buffer.remaining(),Matchers.greaterThan(0)); - // max header table size reached + // max dynamic table size reached Assert.assertEquals(5,encoder.getContext().size()); } @@ -167,7 +167,7 @@ public class HpackEncoderTest // something was encoded! assertThat(buffer.remaining(),Matchers.greaterThan(0)); - // empty header table + // empty dynamic table Assert.assertEquals(0,encoder.getContext().size()); @@ -179,7 +179,7 @@ public class HpackEncoderTest // something was encoded! assertThat(buffer.remaining(),Matchers.greaterThan(0)); - // empty header table + // empty dynamic table Assert.assertEquals(0,encoder.getContext().size()); } diff --git a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackPerfTest.java b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackPerfTest.java index 79d93ce8005..97348b200ca 100644 --- a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackPerfTest.java +++ b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackPerfTest.java @@ -38,7 +38,7 @@ import org.junit.Test; public class HpackPerfTest { - int _maxHeaderTableSize=4*1024; + int _maxDynamicTableSize=4*1024; int _unencodedSize; int _encodedSize; @@ -52,17 +52,17 @@ public class HpackPerfTest @After public void after() { - System.err.printf("headertable=%d unencoded=%d encoded=%d p=%3.1f%%%n",_maxHeaderTableSize,_unencodedSize,_encodedSize,100.0*_encodedSize/_unencodedSize); + System.err.printf("dynamictable=%d unencoded=%d encoded=%d p=%3.1f%%%n",_maxDynamicTableSize,_unencodedSize,_encodedSize,100.0*_encodedSize/_unencodedSize); } @Test public void simpleTest() throws Exception { - runStories(_maxHeaderTableSize); + runStories(_maxDynamicTableSize); } - private void runStories(int maxHeaderTableSize) throws Exception + private void runStories(int maxDynamicTableSize) throws Exception { // Find files File data = MavenTestingUtils.getTestResourceDir("data"); @@ -101,7 +101,7 @@ public class HpackPerfTest { if (type.equals(story.get("context"))) { - HpackEncoder encoder = new HpackEncoder(_maxHeaderTableSize,_maxHeaderTableSize); + HpackEncoder encoder = new HpackEncoder(_maxDynamicTableSize,_maxDynamicTableSize); // System.err.println(story); Object[] cases = (Object[])story.get("cases"); diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java index 2bb1c786d2b..488cde554a2 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java @@ -34,7 +34,7 @@ import org.eclipse.jetty.server.Connector; public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConnectionFactory { private boolean dispatchIO = true; - private int maxHeaderTableSize = 4096; + private int maxDynamicTableSize = 4096; private int initialStreamWindow = FlowControl.DEFAULT_WINDOW_SIZE; private int maxConcurrentStreams = -1; @@ -53,14 +53,14 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne this.dispatchIO = dispatchIO; } - public int getMaxHeaderTableSize() + public int getMaxDynamicTableSize() { - return maxHeaderTableSize; + return maxDynamicTableSize; } public void setMaxHeaderTableSize(int maxHeaderTableSize) { - this.maxHeaderTableSize = maxHeaderTableSize; + this.maxDynamicTableSize = maxHeaderTableSize; } public int getInitialStreamWindow() @@ -88,7 +88,7 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne { ServerSessionListener listener = newSessionListener(connector, endPoint); - Generator generator = new Generator(connector.getByteBufferPool(), getMaxHeaderTableSize()); + Generator generator = new Generator(connector.getByteBufferPool(), getMaxDynamicTableSize()); HTTP2ServerSession session = new HTTP2ServerSession(connector.getScheduler(), endPoint, generator, listener, new HTTP2FlowControl(getInitialStreamWindow())); session.setMaxLocalStreams(getMaxConcurrentStreams()); diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java index eba06e97ac9..eea92869e60 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java @@ -62,7 +62,7 @@ public class HTTP2ServerConnectionFactory extends AbstractHTTP2ServerConnectionF @Override protected ServerParser newServerParser(ByteBufferPool byteBufferPool, ServerParser.Listener listener) { - return new ServerParser(byteBufferPool, listener, getMaxHeaderTableSize(), httpConfiguration.getRequestHeaderSize()); + return new ServerParser(byteBufferPool, listener, getMaxDynamicTableSize(), httpConfiguration.getRequestHeaderSize()); } @@ -87,7 +87,7 @@ public class HTTP2ServerConnectionFactory extends AbstractHTTP2ServerConnectionF public Map onPreface(Session session) { Map settings = new HashMap<>(); - settings.put(SettingsFrame.HEADER_TABLE_SIZE, getMaxHeaderTableSize()); + settings.put(SettingsFrame.HEADER_TABLE_SIZE, getMaxDynamicTableSize()); settings.put(SettingsFrame.INITIAL_WINDOW_SIZE, getInitialStreamWindow()); int maxConcurrentStreams = getMaxConcurrentStreams(); if (maxConcurrentStreams >= 0) diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/RawHTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/RawHTTP2ServerConnectionFactory.java index 5a441f30e39..c5837bda8a8 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/RawHTTP2ServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/RawHTTP2ServerConnectionFactory.java @@ -43,6 +43,6 @@ public class RawHTTP2ServerConnectionFactory extends AbstractHTTP2ServerConnecti protected ServerParser newServerParser(ByteBufferPool byteBufferPool, ServerParser.Listener listener) { // TODO: make maxHeaderSize configurable. - return new ServerParser(byteBufferPool, listener, getMaxHeaderTableSize(), 8192); + return new ServerParser(byteBufferPool, listener, getMaxDynamicTableSize(), 8192); } }