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 78dca539a70..abd791e64e3 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 @@ -31,23 +31,20 @@ import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; - -/* ------------------------------------------------------------ */ /** * Hpack Decoder - *
This is not thread safe and may only be called by 1 thread at a time + *
This is not thread safe and may only be called by 1 thread at a time.
*/ public class HpackDecoder { public static final Logger LOG = Log.getLogger(HpackDecoder.class); - public final static HttpField.LongValueHttpField CONTENT_LENGTH_0 = + public final static HttpField.LongValueHttpField CONTENT_LENGTH_0 = new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH,0L); - + private final HpackContext _context; private final MetaDataBuilder _builder; private int _localMaxDynamicTableSize; - /* ------------------------------------------------------------ */ /** * @param localMaxDynamicTableSize The maximum allowed size of the local dynamic header field table. * @param maxHeaderSize The maximum allowed size of a headers block, expressed as total of all name and value characters. @@ -58,36 +55,38 @@ public class HpackDecoder _localMaxDynamicTableSize=localMaxDynamicTableSize; _builder = new MetaDataBuilder(maxHeaderSize); } - + public HpackContext getHpackContext() { return _context; } - + public void setLocalMaxDynamicTableSize(int localMaxdynamciTableSize) { - _localMaxDynamicTableSize=localMaxdynamciTableSize; + _localMaxDynamicTableSize=localMaxdynamciTableSize; } - + public MetaData decode(ByteBuffer buffer) - { + { if (LOG.isDebugEnabled()) LOG.debug(String.format("CtxTbl[%x] decoding %d octets",_context.hashCode(),buffer.remaining())); - + // If the buffer is big, don't even think about decoding it if (buffer.remaining()>_builder.getMaxSize()) throw new BadMessageException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413,"Header frame size "+buffer.remaining()+">"+_builder.getMaxSize()); - - + + while(buffer.hasRemaining()) { if (LOG.isDebugEnabled()) - { + { int l=Math.min(buffer.remaining(),16); // TODO: not guaranteed the buffer has a backing array ! - LOG.debug("decode "+TypeUtil.toHexString(buffer.array(),buffer.arrayOffset()+buffer.position(),l)+(l