Refactor names of HPACK to QPACK

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2021-02-03 14:58:02 +11:00 committed by Simone Bordet
parent ee042b173a
commit f8d2d9c600
17 changed files with 170 additions and 169 deletions

View File

@ -12,6 +12,7 @@
//
import org.eclipse.jetty.http.HttpFieldPreEncoder;
import org.eclipse.jetty.http3.qpack.QpackFieldPreEncoder;
module org.eclipse.jetty.http3.qpack
{
@ -20,5 +21,5 @@ module org.eclipse.jetty.http3.qpack
requires transitive org.eclipse.jetty.http;
requires org.slf4j;
provides HttpFieldPreEncoder with HpackFieldPreEncoder;
provides HttpFieldPreEncoder with QpackFieldPreEncoder;
}

View File

@ -21,7 +21,7 @@ import org.eclipse.jetty.http.HttpHeader;
*/
public class AuthorityHttpField extends HostPortHttpField
{
public static final String AUTHORITY = HpackContext.STATIC_TABLE[1][0];
public static final String AUTHORITY = QpackContext.STATIC_TABLE[1][0];
public AuthorityHttpField(String authority)
{

View File

@ -348,12 +348,12 @@ public class Huffman
}
}
public static String decode(ByteBuffer buffer) throws HpackException.CompressionException
public static String decode(ByteBuffer buffer) throws QpackException.CompressionException
{
return decode(buffer, buffer.remaining());
}
public static String decode(ByteBuffer buffer, int length) throws HpackException.CompressionException
public static String decode(ByteBuffer buffer, int length) throws QpackException.CompressionException
{
Utf8StringBuilder utf8 = new Utf8StringBuilder(length * 2);
int node = 0;
@ -372,7 +372,7 @@ public class Huffman
if (rowbits[node] != 0)
{
if (rowsym[node] == EOS)
throw new HpackException.CompressionException("EOS in content");
throw new QpackException.CompressionException("EOS in content");
// terminal node
utf8.append((byte)(0xFF & rowsym[node]));
@ -402,7 +402,7 @@ public class Huffman
}
if ((c >> (8 - bits)) != requiredPadding)
throw new HpackException.CompressionException("Incorrect padding");
throw new QpackException.CompressionException("Incorrect padding");
node = lastNode;
break;
@ -414,7 +414,7 @@ public class Huffman
}
if (node != 0)
throw new HpackException.CompressionException("Bad termination");
throw new QpackException.CompressionException("Bad termination");
return utf8.toString();
}

View File

@ -21,7 +21,7 @@ import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http3.qpack.HpackException.SessionException;
import org.eclipse.jetty.http3.qpack.QpackException.SessionException;
public class MetaDataBuilder
{
@ -35,7 +35,7 @@ public class MetaDataBuilder
private String _path;
private String _protocol;
private long _contentLength = Long.MIN_VALUE;
private HpackException.StreamException _streamException;
private QpackException.StreamException _streamException;
private boolean _request;
private boolean _response;
@ -67,17 +67,17 @@ public class MetaDataBuilder
return _size;
}
public void emit(HttpField field) throws HpackException.SessionException
public void emit(HttpField field) throws QpackException.SessionException
{
HttpHeader header = field.getHeader();
String name = field.getName();
if (name == null || name.length() == 0)
throw new HpackException.SessionException("Header size 0");
throw new QpackException.SessionException("Header size 0");
String value = field.getValue();
int fieldSize = name.length() + (value == null ? 0 : value.length());
_size += fieldSize + 32;
if (_size > _maxSize)
throw new HpackException.SessionException("Header size %d > %d", _size, _maxSize);
throw new QpackException.SessionException("Header size %d > %d", _size, _maxSize);
if (field instanceof StaticTableHttpField)
{
@ -198,7 +198,7 @@ public class MetaDataBuilder
protected void streamException(String messageFormat, Object... args)
{
HpackException.StreamException stream = new HpackException.StreamException(messageFormat, args);
QpackException.StreamException stream = new QpackException.StreamException(messageFormat, args);
if (_streamException == null)
_streamException = stream;
else
@ -218,7 +218,7 @@ public class MetaDataBuilder
return false;
}
public MetaData build() throws HpackException.StreamException
public MetaData build() throws QpackException.StreamException
{
if (_streamException != null)
{
@ -227,7 +227,7 @@ public class MetaDataBuilder
}
if (_request && _response)
throw new HpackException.StreamException("Request and Response headers");
throw new QpackException.StreamException("Request and Response headers");
HttpFields.Mutable fields = _fields;
try
@ -235,14 +235,14 @@ public class MetaDataBuilder
if (_request)
{
if (_method == null)
throw new HpackException.StreamException("No Method");
throw new QpackException.StreamException("No Method");
boolean isConnect = HttpMethod.CONNECT.is(_method);
if (!isConnect || _protocol != null)
{
if (_scheme == null)
throw new HpackException.StreamException("No Scheme");
throw new QpackException.StreamException("No Scheme");
if (_path == null)
throw new HpackException.StreamException("No Path");
throw new QpackException.StreamException("No Path");
}
if (isConnect)
return new MetaData.ConnectRequest(_scheme, _authority, _path, fields, _protocol);
@ -259,7 +259,7 @@ public class MetaDataBuilder
if (_response)
{
if (_status == null)
throw new HpackException.StreamException("No Status");
throw new QpackException.StreamException("No Status");
return new MetaData.Response(HttpVersion.HTTP_2, _status, fields, _contentLength);
}
@ -294,6 +294,6 @@ public class MetaDataBuilder
if (huffman)
length = (length * 4) / 3;
if ((_size + length) > _maxSize)
throw new HpackException.SessionException("Header too large %d > %d", _size + length, _maxSize);
throw new QpackException.SessionException("Header too large %d > %d", _size + length, _maxSize);
}
}

View File

@ -30,16 +30,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* HPACK - Header Compression for HTTP/2
* QPACK - Header Compression for HTTP/2
* <p>This class maintains the compression context for a single HTTP/2
* connection. Specifically it holds the static and dynamic Header Field Tables
* and the associated sizes and limits.
* </p>
* <p>It is compliant with draft 11 of the specification</p>
*/
public class HpackContext
public class QpackContext
{
public static final Logger LOG = LoggerFactory.getLogger(HpackContext.class);
public static final Logger LOG = LoggerFactory.getLogger(QpackContext.class);
private static final String EMPTY = "";
public static final String[][] STATIC_TABLE =
{
@ -187,7 +187,7 @@ public class HpackContext
private final Map<HttpField, Entry> _fieldMap = new HashMap<>();
private final Map<String, Entry> _nameMap = new HashMap<>();
HpackContext(int maxDynamicTableSize)
QpackContext(int maxDynamicTableSize)
{
_maxDynamicTableSizeInBytes = maxDynamicTableSize;
int guesstimateEntries = 10 + maxDynamicTableSize / (32 + 10 + 10);
@ -310,7 +310,7 @@ public class HpackContext
@Override
public String toString()
{
return String.format("HpackContext@%x{entries=%d,size=%d,max=%d}", hashCode(), _dynamicTable.size(), _dynamicTableSizeInBytes, _maxDynamicTableSizeInBytes);
return String.format("QpackContext@%x{entries=%d,size=%d,max=%d}", hashCode(), _dynamicTable.size(), _dynamicTableSizeInBytes, _maxDynamicTableSizeInBytes);
}
private class DynamicTable
@ -373,7 +373,7 @@ public class HpackContext
_offset = (_offset + 1) % _entries.length;
_size--;
if (LOG.isDebugEnabled())
LOG.debug(String.format("HdrTbl[%x] evict %s", HpackContext.this.hashCode(), entry));
LOG.debug(String.format("HdrTbl[%x] evict %s", QpackContext.this.hashCode(), entry));
_dynamicTableSizeInBytes -= entry.getSize();
entry._slot = -1;
_fieldMap.remove(entry.getHttpField());
@ -382,13 +382,13 @@ public class HpackContext
_nameMap.remove(lc);
}
if (LOG.isDebugEnabled())
LOG.debug(String.format("HdrTbl[%x] entries=%d, size=%d, max=%d", HpackContext.this.hashCode(), _dynamicTable.size(), _dynamicTableSizeInBytes, _maxDynamicTableSizeInBytes));
LOG.debug(String.format("HdrTbl[%x] entries=%d, size=%d, max=%d", QpackContext.this.hashCode(), _dynamicTable.size(), _dynamicTableSizeInBytes, _maxDynamicTableSizeInBytes));
}
private void evictAll()
{
if (LOG.isDebugEnabled())
LOG.debug(String.format("HdrTbl[%x] evictAll", HpackContext.this.hashCode()));
LOG.debug(String.format("HdrTbl[%x] evictAll", QpackContext.this.hashCode()));
if (size() > 0)
{
_fieldMap.clear();

View File

@ -19,22 +19,22 @@ import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpTokens;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http3.qpack.HpackContext.Entry;
import org.eclipse.jetty.http3.qpack.QpackContext.Entry;
import org.eclipse.jetty.util.BufferUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Hpack Decoder
* Qpack Decoder
* <p>This is not thread safe and may only be called by 1 thread at a time.</p>
*/
public class HpackDecoder
public class QpackDecoder
{
public static final Logger LOG = LoggerFactory.getLogger(HpackDecoder.class);
public static final Logger LOG = LoggerFactory.getLogger(QpackDecoder.class);
public static final HttpField.LongValueHttpField CONTENT_LENGTH_0 =
new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH, 0L);
private final HpackContext _context;
private final QpackContext _context;
private final MetaDataBuilder _builder;
private int _localMaxDynamicTableSize;
@ -42,14 +42,14 @@ public class HpackDecoder
* @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, plus 32 per field
*/
public HpackDecoder(int localMaxDynamicTableSize, int maxHeaderSize)
public QpackDecoder(int localMaxDynamicTableSize, int maxHeaderSize)
{
_context = new HpackContext(localMaxDynamicTableSize);
_context = new QpackContext(localMaxDynamicTableSize);
_localMaxDynamicTableSize = localMaxDynamicTableSize;
_builder = new MetaDataBuilder(maxHeaderSize);
}
public HpackContext getHpackContext()
public QpackContext getQpackContext()
{
return _context;
}
@ -59,14 +59,14 @@ public class HpackDecoder
_localMaxDynamicTableSize = localMaxdynamciTableSize;
}
public MetaData decode(ByteBuffer buffer) throws HpackException.SessionException, HpackException.StreamException
public MetaData decode(ByteBuffer buffer) throws QpackException.SessionException, QpackException.StreamException
{
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 HpackException.SessionException("431 Request Header Fields too large");
throw new QpackException.SessionException("431 Request Header Fields too large");
boolean emitted = false;
@ -82,7 +82,7 @@ public class HpackDecoder
int index = NBitInteger.decode(buffer, 7);
Entry entry = _context.get(index);
if (entry == null)
throw new HpackException.SessionException("Unknown index %d", index);
throw new QpackException.SessionException("Unknown index %d", index);
if (entry.isStatic())
{
@ -126,7 +126,7 @@ public class HpackDecoder
if (size > _localMaxDynamicTableSize)
throw new IllegalArgumentException();
if (emitted)
throw new HpackException.CompressionException("Dynamic table resize after fields");
throw new QpackException.CompressionException("Dynamic table resize after fields");
_context.resize(size);
continue;
@ -280,6 +280,6 @@ public class HpackDecoder
@Override
public String toString()
{
return String.format("HpackDecoder@%x{%s}", hashCode(), _context);
return String.format("QpackDecoder@%x{%s}", hashCode(), _context);
}
}

View File

@ -29,16 +29,16 @@ import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http.PreEncodedHttpField;
import org.eclipse.jetty.http3.qpack.HpackContext.Entry;
import org.eclipse.jetty.http3.qpack.HpackContext.StaticEntry;
import org.eclipse.jetty.http3.qpack.QpackContext.Entry;
import org.eclipse.jetty.http3.qpack.QpackContext.StaticEntry;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HpackEncoder
public class QpackEncoder
{
private static final Logger LOG = LoggerFactory.getLogger(HpackEncoder.class);
private static final Logger LOG = LoggerFactory.getLogger(QpackEncoder.class);
private static final HttpField[] STATUSES = new HttpField[599];
static final EnumSet<HttpHeader> DO_NOT_HUFFMAN =
EnumSet.of(
@ -90,7 +90,7 @@ public class HpackEncoder
}
}
private final HpackContext _context;
private final QpackContext _context;
private final boolean _debug;
private int _remoteMaxDynamicTableSize;
private int _localMaxDynamicTableSize;
@ -98,24 +98,24 @@ public class HpackEncoder
private int _headerListSize;
private boolean _validateEncoding = true;
public HpackEncoder()
public QpackEncoder()
{
this(4096, 4096, -1);
}
public HpackEncoder(int localMaxDynamicTableSize)
public QpackEncoder(int localMaxDynamicTableSize)
{
this(localMaxDynamicTableSize, 4096, -1);
}
public HpackEncoder(int localMaxDynamicTableSize, int remoteMaxDynamicTableSize)
public QpackEncoder(int localMaxDynamicTableSize, int remoteMaxDynamicTableSize)
{
this(localMaxDynamicTableSize, remoteMaxDynamicTableSize, -1);
}
public HpackEncoder(int localMaxDynamicTableSize, int remoteMaxDynamicTableSize, int maxHeaderListSize)
public QpackEncoder(int localMaxDynamicTableSize, int remoteMaxDynamicTableSize, int maxHeaderListSize)
{
_context = new HpackContext(remoteMaxDynamicTableSize);
_context = new QpackContext(remoteMaxDynamicTableSize);
_remoteMaxDynamicTableSize = remoteMaxDynamicTableSize;
_localMaxDynamicTableSize = localMaxDynamicTableSize;
_maxHeaderListSize = maxHeaderListSize;
@ -132,7 +132,7 @@ public class HpackEncoder
_maxHeaderListSize = maxHeaderListSize;
}
public HpackContext getHpackContext()
public QpackContext getQpackContext()
{
return _context;
}
@ -157,7 +157,7 @@ public class HpackEncoder
_validateEncoding = validateEncoding;
}
public void encode(ByteBuffer buffer, MetaData metadata) throws HpackException
public void encode(ByteBuffer buffer, MetaData metadata) throws QpackException
{
try
{
@ -173,7 +173,7 @@ public class HpackEncoder
String name = field.getName();
char firstChar = name.charAt(0);
if (firstChar <= ' ' || firstChar == ':')
throw new HpackException.StreamException("Invalid header name: '%s'", name);
throw new QpackException.StreamException("Invalid header name: '%s'", name);
}
}
@ -269,13 +269,13 @@ public class HpackEncoder
if (LOG.isDebugEnabled())
LOG.debug(String.format("CtxTbl[%x] encoded %d octets", _context.hashCode(), buffer.position() - pos));
}
catch (HpackException x)
catch (QpackException x)
{
throw x;
}
catch (Throwable x)
{
HpackException.SessionException failure = new HpackException.SessionException("Could not hpack encode %s", metadata);
QpackException.SessionException failure = new QpackException.SessionException("Could not qpack encode %s", metadata);
failure.initCause(x);
throw failure;
}

View File

@ -14,21 +14,21 @@
package org.eclipse.jetty.http3.qpack;
@SuppressWarnings("serial")
public abstract class HpackException extends Exception
public abstract class QpackException extends Exception
{
HpackException(String messageFormat, Object... args)
QpackException(String messageFormat, Object... args)
{
super(String.format(messageFormat, args));
}
/**
* A Stream HPACK exception.
* A Stream QPACK exception.
* <p>Stream exceptions are not fatal to the connection and the
* hpack state is complete and able to continue handling other
* qpack state is complete and able to continue handling other
* decoding/encoding for the session.
* </p>
*/
public static class StreamException extends HpackException
public static class StreamException extends QpackException
{
StreamException(String messageFormat, Object... args)
{
@ -37,11 +37,11 @@ public abstract class HpackException extends Exception
}
/**
* A Session HPACK Exception.
* <p>Session exceptions are fatal for the stream and the HPACK
* A Session QPACK Exception.
* <p>Session exceptions are fatal for the stream and the QPACK
* state is unable to decode/encode further. </p>
*/
public static class SessionException extends HpackException
public static class SessionException extends QpackException
{
SessionException(String messageFormat, Object... args)
{

View File

@ -23,7 +23,7 @@ import org.eclipse.jetty.util.BufferUtil;
/**
*
*/
public class HpackFieldPreEncoder implements HttpFieldPreEncoder
public class QpackFieldPreEncoder implements HttpFieldPreEncoder
{
@Override
@ -35,7 +35,7 @@ public class HpackFieldPreEncoder implements HttpFieldPreEncoder
@Override
public byte[] getEncodedField(HttpHeader header, String name, String value)
{
boolean notIndexed = HpackEncoder.DO_NOT_INDEX.contains(header);
boolean notIndexed = QpackEncoder.DO_NOT_INDEX.contains(header);
ByteBuffer buffer = BufferUtil.allocate(name.length() + value.length() + 10);
BufferUtil.clearToFill(buffer);
@ -45,8 +45,8 @@ public class HpackFieldPreEncoder implements HttpFieldPreEncoder
if (notIndexed)
{
// Non indexed field
boolean neverIndex = HpackEncoder.NEVER_INDEX.contains(header);
huffman = !HpackEncoder.DO_NOT_HUFFMAN.contains(header);
boolean neverIndex = QpackEncoder.NEVER_INDEX.contains(header);
huffman = !QpackEncoder.DO_NOT_HUFFMAN.contains(header);
buffer.put(neverIndex ? (byte)0x10 : (byte)0x00);
bits = 4;
}
@ -61,11 +61,11 @@ public class HpackFieldPreEncoder implements HttpFieldPreEncoder
{
// indexed
buffer.put((byte)0x40);
huffman = !HpackEncoder.DO_NOT_HUFFMAN.contains(header);
huffman = !QpackEncoder.DO_NOT_HUFFMAN.contains(header);
bits = 6;
}
int nameIdx = HpackContext.staticIndex(header);
int nameIdx = QpackContext.staticIndex(header);
if (nameIdx > 0)
NBitInteger.encode(buffer, bits, nameIdx);
else
@ -75,7 +75,7 @@ public class HpackFieldPreEncoder implements HttpFieldPreEncoder
Huffman.encodeLC(buffer, name);
}
HpackEncoder.encodeValue(buffer, huffman, value);
QpackEncoder.encodeValue(buffer, huffman, value);
BufferUtil.flipToFlush(buffer, 0);
return BufferUtil.toArray(buffer);

View File

@ -1 +1 @@
org.eclipse.jetty.http3.qpack.HpackFieldPreEncoder
org.eclipse.jetty.http3.qpack.QpackFieldPreEncoder

View File

@ -16,7 +16,7 @@ package org.eclipse.jetty.http3.qpack;
import java.nio.ByteBuffer;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http3.qpack.HpackContext.Entry;
import org.eclipse.jetty.http3.qpack.QpackContext.Entry;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
@ -30,13 +30,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
*/
public class HpackContextTest
public class QpackContextTest
{
@Test
public void testStaticName()
{
HpackContext ctx = new HpackContext(4096);
QpackContext ctx = new QpackContext(4096);
Entry entry = ctx.get(":method");
assertEquals(":method", entry.getHttpField().getName());
assertTrue(entry.isStatic());
@ -46,7 +46,7 @@ public class HpackContextTest
@Test
public void testEmptyAdd()
{
HpackContext ctx = new HpackContext(0);
QpackContext ctx = new QpackContext(0);
HttpField field = new HttpField("foo", "bar");
assertNull(ctx.add(field));
}
@ -54,7 +54,7 @@ public class HpackContextTest
@Test
public void testTooBigAdd()
{
HpackContext ctx = new HpackContext(37);
QpackContext ctx = new QpackContext(37);
HttpField field = new HttpField("foo", "bar");
assertNull(ctx.add(field));
}
@ -62,7 +62,7 @@ public class HpackContextTest
@Test
public void testJustRight()
{
HpackContext ctx = new HpackContext(38);
QpackContext ctx = new QpackContext(38);
HttpField field = new HttpField("foo", "bar");
Entry entry = ctx.add(field);
assertNotNull(entry);
@ -72,7 +72,7 @@ public class HpackContextTest
@Test
public void testEvictOne()
{
HpackContext ctx = new HpackContext(38);
QpackContext ctx = new QpackContext(38);
HttpField field0 = new HttpField("foo", "bar");
assertEquals(field0, ctx.add(field0).getHttpField());
@ -90,7 +90,7 @@ public class HpackContextTest
@Test
public void testEvictNames()
{
HpackContext ctx = new HpackContext(38 * 2);
QpackContext ctx = new QpackContext(38 * 2);
HttpField[] field =
{
new HttpField("name", "v0"),
@ -129,7 +129,7 @@ public class HpackContextTest
@SuppressWarnings("ReferenceEquality")
public void testGetAddStatic()
{
HpackContext ctx = new HpackContext(4096);
QpackContext ctx = new QpackContext(4096);
// Look for the field. Should find static version.
HttpField methodGet = new HttpField(":method", "GET");
@ -157,7 +157,7 @@ public class HpackContextTest
@Test
public void testGetAddStaticName()
{
HpackContext ctx = new HpackContext(4096);
QpackContext ctx = new QpackContext(4096);
HttpField methodOther = new HttpField(":method", "OTHER");
// Look for the field by name. Should find static version.
@ -176,7 +176,7 @@ public class HpackContextTest
public void testIndexes()
{
// Only enough space for 5 entries
HpackContext ctx = new HpackContext(38 * 5);
QpackContext ctx = new QpackContext(38 * 5);
HttpField methodPost = new HttpField(":method", "POST");
HttpField[] field =
@ -304,7 +304,7 @@ public class HpackContextTest
public void testResize()
{
// Only enough space for 5 entries
HpackContext ctx = new HpackContext(38 * 5);
QpackContext ctx = new QpackContext(38 * 5);
HttpField[] field =
{
@ -413,7 +413,7 @@ public class HpackContextTest
@Test
public void testStaticHuffmanValues() throws Exception
{
HpackContext ctx = new HpackContext(4096);
QpackContext ctx = new QpackContext(4096);
for (int i = 2; i <= 14; i++)
{
Entry entry = ctx.get(i);
@ -435,7 +435,7 @@ public class HpackContextTest
@Test
public void testNameInsensitivity()
{
HpackContext ctx = new HpackContext(4096);
QpackContext ctx = new QpackContext(4096);
assertEquals("content-length", ctx.get("content-length").getHttpField().getName());
assertEquals("content-length", ctx.get("Content-Length").getHttpField().getName());
assertTrue(ctx.get("Content-Length").isStatic());

View File

@ -20,9 +20,9 @@ import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http3.qpack.HpackException.CompressionException;
import org.eclipse.jetty.http3.qpack.HpackException.SessionException;
import org.eclipse.jetty.http3.qpack.HpackException.StreamException;
import org.eclipse.jetty.http3.qpack.QpackException.CompressionException;
import org.eclipse.jetty.http3.qpack.QpackException.SessionException;
import org.eclipse.jetty.http3.qpack.QpackException.StreamException;
import org.eclipse.jetty.util.TypeUtil;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
public class HpackDecoderTest
public class QpackDecoderTest
{
/*
0 1 2 3 4 5 6 7
@ -57,7 +57,7 @@ public class HpackDecoderTest
@Test
public void testDecodeD3() throws Exception
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
// First request
String encoded = "828684410f7777772e6578616d706c652e636f6d";
@ -105,7 +105,7 @@ public class HpackDecoderTest
@Test
public void testDecodeD4() throws Exception
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
// First request
String encoded = "828684418cf1e3c2e5f23a6ba0ab90f4ff";
@ -140,7 +140,7 @@ public class HpackDecoderTest
{
String value = "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==";
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "8682418cF1E3C2E5F23a6bA0Ab90F4Ff841f0822426173696320515778685a475270626a70766347567549484e6c633246745a513d3d";
byte[] bytes = TypeUtil.fromHexString(encoded);
byte[] array = new byte[bytes.length + 1];
@ -162,7 +162,7 @@ public class HpackDecoderTest
@Test
public void testDecodeHuffmanWithArrayOffset() throws Exception
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "8286418cf1e3c2e5f23a6ba0ab90f4ff84";
byte[] bytes = TypeUtil.fromHexString(encoded);
@ -186,7 +186,7 @@ public class HpackDecoderTest
String encoded = "886196C361Be940b6a65B6850400B8A00571972e080a62D1Bf5f87497cA589D34d1f9a0f0d0234327690Aa69D29aFcA954D3A5358980Ae112e0f7c880aE152A9A74a6bF3";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
MetaData.Response response = (MetaData.Response)decoder.decode(buffer);
assertThat(response.getStatus(), is(200));
@ -204,12 +204,12 @@ public class HpackDecoderTest
{
String encoded = "203f136687A0E41d139d090760881c6490B2Cd39Ba7f";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
MetaData metaData = decoder.decode(buffer);
assertThat(metaData.getFields().get(HttpHeader.HOST), is("localhost0"));
assertThat(metaData.getFields().get(HttpHeader.COOKIE), is("abcdefghij"));
assertThat(decoder.getHpackContext().getMaxDynamicTableSize(), is(50));
assertThat(decoder.getHpackContext().size(), is(1));
assertThat(decoder.getQpackContext().getMaxDynamicTableSize(), is(50));
assertThat(decoder.getQpackContext().size(), is(1));
}
@Test
@ -226,7 +226,7 @@ public class HpackDecoderTest
String encoded = "203f136687A0E41d139d090760881c6490B2Cd39Ba7f20";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
try
{
decoder.decode(buffer);
@ -244,10 +244,10 @@ public class HpackDecoderTest
String encoded = "3f610f17FfEc02Df3990A190A0D4Ee5b3d2940Ec98Aa4a62D127D29e273a0aA20dEcAa190a503b262d8a2671D4A2672a927aA874988a2471D05510750c951139EdA2452a3a548cAa1aA90bE4B228342864A9E0D450A5474a92992a1aA513395448E3A0Aa17B96cFe3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f14E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F3E7Cf9f3e7cF9F353F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F54f";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
HpackDecoder decoder = new HpackDecoder(128, 8192);
QpackDecoder decoder = new QpackDecoder(128, 8192);
MetaData metaData = decoder.decode(buffer);
assertThat(decoder.getHpackContext().getDynamicTableSize(), is(0));
assertThat(decoder.getQpackContext().getDynamicTableSize(), is(0));
assertThat(metaData.getFields().get("host"), Matchers.startsWith("This is a very large field"));
}
@ -257,7 +257,7 @@ public class HpackDecoderTest
String encoded = "BE";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
HpackDecoder decoder = new HpackDecoder(128, 8192);
QpackDecoder decoder = new QpackDecoder(128, 8192);
try
{
@ -442,7 +442,7 @@ public class HpackDecoderTest
@Test
public void testHuffmanEncodedStandard() throws Exception
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "82868441" + "83" + "49509F";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
@ -460,7 +460,7 @@ public class HpackDecoderTest
@Test
public void testHuffmanEncodedExtraPadding()
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "82868441" + "84" + "49509FFF";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
@ -472,7 +472,7 @@ public class HpackDecoderTest
@Test
public void testHuffmanEncodedZeroPadding()
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "82868441" + "83" + "495090";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
@ -485,7 +485,7 @@ public class HpackDecoderTest
@Test
public void testHuffmanEncodedWithEOS()
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "82868441" + "87" + "497FFFFFFF427F";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
@ -497,7 +497,7 @@ public class HpackDecoderTest
@Test
public void testHuffmanEncodedOneIncompleteOctet()
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "82868441" + "81" + "FE";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
@ -509,7 +509,7 @@ public class HpackDecoderTest
@Test
public void testHuffmanEncodedTwoIncompleteOctet()
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "82868441" + "82" + "FFFE";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
@ -521,7 +521,7 @@ public class HpackDecoderTest
@Test
public void testZeroLengthName()
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "00000130";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
@ -532,7 +532,7 @@ public class HpackDecoderTest
@Test
public void testZeroLengthValue() throws Exception
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "00016800";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
@ -544,7 +544,7 @@ public class HpackDecoderTest
@Test
public void testUpperCaseName()
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "0001480130";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));
@ -555,7 +555,7 @@ public class HpackDecoderTest
@Test
public void testWhiteSpaceName()
{
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackDecoder decoder = new QpackDecoder(4096, 8192);
String encoded = "0001200130";
ByteBuffer buffer = ByteBuffer.wrap(TypeUtil.fromHexString(encoded));

View File

@ -28,12 +28,12 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class HpackEncoderTest
public class QpackEncoderTest
{
@Test
public void testUnknownFieldsContextManagement() throws Exception
{
HpackEncoder encoder = new HpackEncoder(38 * 5);
QpackEncoder encoder = new QpackEncoder(38 * 5);
HttpFields.Mutable fields = HttpFields.build();
HttpField[] field =
@ -67,7 +67,7 @@ public class HpackEncoderTest
assertThat(buffer.remaining(), Matchers.greaterThan(0));
// All are in the dynamic table
assertEquals(4, encoder.getHpackContext().size());
assertEquals(4, encoder.getQpackContext().size());
// encode exact same fields again!
BufferUtil.clearToFill(buffer);
@ -75,7 +75,7 @@ public class HpackEncoderTest
BufferUtil.flipToFlush(buffer, 0);
// All are in the dynamic table
assertEquals(4, encoder.getHpackContext().size());
assertEquals(4, encoder.getQpackContext().size());
// Add 4 more fields
for (int i = 4; i <= 7; i++)
@ -92,7 +92,7 @@ public class HpackEncoderTest
assertThat(buffer.remaining(), Matchers.greaterThan(0));
// max dynamic table size reached
assertEquals(5, encoder.getHpackContext().size());
assertEquals(5, encoder.getQpackContext().size());
// remove some fields
for (int i = 0; i <= 7; i += 2)
@ -109,7 +109,7 @@ public class HpackEncoderTest
assertThat(buffer.remaining(), Matchers.greaterThan(0));
// max dynamic table size reached
assertEquals(5, encoder.getHpackContext().size());
assertEquals(5, encoder.getQpackContext().size());
// remove another fields
fields.remove(field[1].getName());
@ -123,7 +123,7 @@ public class HpackEncoderTest
assertThat(buffer.remaining(), Matchers.greaterThan(0));
// max dynamic table size reached
assertEquals(5, encoder.getHpackContext().size());
assertEquals(5, encoder.getQpackContext().size());
// re add the field
@ -138,14 +138,14 @@ public class HpackEncoderTest
assertThat(buffer.remaining(), Matchers.greaterThan(0));
// max dynamic table size reached
assertEquals(5, encoder.getHpackContext().size());
assertEquals(5, encoder.getQpackContext().size());
}
@Test
public void testLargeFieldsNotIndexed()
{
HpackEncoder encoder = new HpackEncoder(38 * 5);
HpackContext ctx = encoder.getHpackContext();
QpackEncoder encoder = new QpackEncoder(38 * 5);
QpackContext ctx = encoder.getQpackContext();
ByteBuffer buffer = BufferUtil.allocate(4096);
@ -170,8 +170,8 @@ public class HpackEncoderTest
@Test
public void testIndexContentLength()
{
HpackEncoder encoder = new HpackEncoder(38 * 5);
HpackContext ctx = encoder.getHpackContext();
QpackEncoder encoder = new QpackEncoder(38 * 5);
QpackContext ctx = encoder.getQpackContext();
ByteBuffer buffer = BufferUtil.allocate(4096);
@ -192,7 +192,7 @@ public class HpackEncoderTest
@Test
public void testNeverIndexSetCookie() throws Exception
{
HpackEncoder encoder = new HpackEncoder(38 * 5);
QpackEncoder encoder = new QpackEncoder(38 * 5);
ByteBuffer buffer = BufferUtil.allocate(4096);
HttpFields.Mutable fields = HttpFields.build()
@ -207,7 +207,7 @@ public class HpackEncoderTest
assertThat(buffer.remaining(), Matchers.greaterThan(0));
// empty dynamic table
assertEquals(0, encoder.getHpackContext().size());
assertEquals(0, encoder.getQpackContext().size());
// encode again
BufferUtil.clearToFill(buffer);
@ -218,7 +218,7 @@ public class HpackEncoderTest
assertThat(buffer.remaining(), Matchers.greaterThan(0));
// empty dynamic table
assertEquals(0, encoder.getHpackContext().size());
assertEquals(0, encoder.getQpackContext().size());
}
@Test
@ -226,20 +226,20 @@ public class HpackEncoderTest
{
HttpFields.Mutable fields = HttpFields.build();
HpackEncoder encoder = new HpackEncoder(128);
QpackEncoder encoder = new QpackEncoder(128);
ByteBuffer buffer0 = BufferUtil.allocate(4096);
int pos = BufferUtil.flipToFill(buffer0);
encoder.encode(buffer0, new MetaData(HttpVersion.HTTP_2, fields));
BufferUtil.flipToFlush(buffer0, pos);
encoder = new HpackEncoder(128);
encoder = new QpackEncoder(128);
fields.add(new HttpField("user-agent", "jetty/test"));
ByteBuffer buffer1 = BufferUtil.allocate(4096);
pos = BufferUtil.flipToFill(buffer1);
encoder.encode(buffer1, new MetaData(HttpVersion.HTTP_2, fields));
BufferUtil.flipToFlush(buffer1, pos);
encoder = new HpackEncoder(128);
encoder = new QpackEncoder(128);
encoder.setValidateEncoding(false);
fields.add(new HttpField(":path",
"This is a very large field, whose size is larger than the dynamic table so it should not be indexed as it will not fit in the table ever!" +
@ -251,7 +251,7 @@ public class HpackEncoderTest
encoder.encode(buffer2, new MetaData(HttpVersion.HTTP_2, fields));
BufferUtil.flipToFlush(buffer2, pos);
encoder = new HpackEncoder(128);
encoder = new QpackEncoder(128);
encoder.setValidateEncoding(false);
fields.add(new HttpField("host", "somehost"));
ByteBuffer buffer = BufferUtil.allocate(4096);
@ -277,12 +277,12 @@ public class HpackEncoderTest
assertThat((buffer.get(buffer2.remaining()) & 0xFF) >> 6, equalTo(1));
// Only first and third fields are put in the table
HpackContext context = encoder.getHpackContext();
QpackContext context = encoder.getQpackContext();
assertThat(context.size(), equalTo(2));
assertThat(context.get(HpackContext.STATIC_SIZE + 1).getHttpField().getName(), equalTo("host"));
assertThat(context.get(HpackContext.STATIC_SIZE + 2).getHttpField().getName(), equalTo("user-agent"));
assertThat(context.get(QpackContext.STATIC_SIZE + 1).getHttpField().getName(), equalTo("host"));
assertThat(context.get(QpackContext.STATIC_SIZE + 2).getHttpField().getName(), equalTo("user-agent"));
assertThat(context.getDynamicTableSize(), equalTo(
context.get(HpackContext.STATIC_SIZE + 1).getSize() + context.get(HpackContext.STATIC_SIZE + 2).getSize()));
context.get(QpackContext.STATIC_SIZE + 1).getSize() + context.get(QpackContext.STATIC_SIZE + 2).getSize()));
}
@Test
@ -292,7 +292,7 @@ public class HpackEncoderTest
.add("host", "localhost0")
.add("cookie", "abcdefghij");
HpackEncoder encoder = new HpackEncoder(4096);
QpackEncoder encoder = new QpackEncoder(4096);
ByteBuffer buffer = BufferUtil.allocate(4096);
int pos = BufferUtil.flipToFill(buffer);
@ -301,7 +301,7 @@ public class HpackEncoderTest
encoder.encode(buffer, new MetaData(HttpVersion.HTTP_2, fields));
BufferUtil.flipToFlush(buffer, pos);
HpackContext context = encoder.getHpackContext();
QpackContext context = encoder.getQpackContext();
assertThat(context.getMaxDynamicTableSize(), Matchers.is(50));
assertThat(context.size(), Matchers.is(1));

View File

@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class HpackPerfTest
public class QpackPerfTest
{
int _maxDynamicTableSize = 4 * 1024;
int _unencodedSize;
@ -92,7 +92,7 @@ public class HpackPerfTest
{
if (type.equals(story.get("context")))
{
HpackEncoder encoder = new HpackEncoder(_maxDynamicTableSize, _maxDynamicTableSize);
QpackEncoder encoder = new QpackEncoder(_maxDynamicTableSize, _maxDynamicTableSize);
encoder.setValidateEncoding(false);
Object[] cases = (Object[])story.get("cases");

View File

@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;
public class HpackTest
public class QpackTest
{
static final HttpField ServerJetty = new PreEncodedHttpField(HttpHeader.SERVER, "jetty");
static final HttpField XPowerJetty = new PreEncodedHttpField(HttpHeader.X_POWERED_BY, "jetty");
@ -43,8 +43,8 @@ public class HpackTest
@Test
public void encodeDecodeResponseTest() throws Exception
{
HpackEncoder encoder = new HpackEncoder();
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackEncoder encoder = new QpackEncoder();
QpackDecoder decoder = new QpackDecoder(4096, 8192);
ByteBuffer buffer = BufferUtil.allocateDirect(16 * 1024);
HttpFields.Mutable fields0 = HttpFields.build()
@ -98,8 +98,8 @@ public class HpackTest
@Test
public void encodeDecodeTooLargeTest() throws Exception
{
HpackEncoder encoder = new HpackEncoder();
HpackDecoder decoder = new HpackDecoder(4096, 164);
QpackEncoder encoder = new QpackEncoder();
QpackDecoder decoder = new QpackDecoder(4096, 164);
ByteBuffer buffer = BufferUtil.allocateDirect(16 * 1024);
HttpFields fields0 = HttpFields.build()
@ -128,7 +128,7 @@ public class HpackTest
decoder.decode(buffer);
fail();
}
catch (HpackException.SessionException e)
catch (QpackException.SessionException e)
{
assertThat(e.getMessage(), containsString("Header too large"));
}
@ -137,8 +137,8 @@ public class HpackTest
@Test
public void encodeDecodeNonAscii() throws Exception
{
HpackEncoder encoder = new HpackEncoder();
HpackDecoder decoder = new HpackDecoder(4096, 8192);
QpackEncoder encoder = new QpackEncoder();
QpackDecoder decoder = new QpackDecoder(4096, 8192);
ByteBuffer buffer = BufferUtil.allocate(16 * 1024);
HttpFields fields0 = HttpFields.build()
@ -158,8 +158,8 @@ public class HpackTest
@Test
public void evictReferencedFieldTest() throws Exception
{
HpackEncoder encoder = new HpackEncoder(200, 200);
HpackDecoder decoder = new HpackDecoder(200, 1024);
QpackEncoder encoder = new QpackEncoder(200, 200);
QpackDecoder decoder = new QpackDecoder(200, 1024);
ByteBuffer buffer = BufferUtil.allocateDirect(16 * 1024);
String longEnoughToBeEvicted = "012345678901234567890123456789012345678901234567890";
@ -174,10 +174,10 @@ public class HpackTest
BufferUtil.flipToFlush(buffer, 0);
MetaData decoded0 = decoder.decode(buffer);
assertEquals(2, encoder.getHpackContext().size());
assertEquals(2, decoder.getHpackContext().size());
assertEquals(longEnoughToBeEvicted, encoder.getHpackContext().get(HpackContext.STATIC_TABLE.length + 1).getHttpField().getName());
assertEquals("foo", encoder.getHpackContext().get(HpackContext.STATIC_TABLE.length).getHttpField().getName());
assertEquals(2, encoder.getQpackContext().size());
assertEquals(2, decoder.getQpackContext().size());
assertEquals(longEnoughToBeEvicted, encoder.getQpackContext().get(QpackContext.STATIC_TABLE.length + 1).getHttpField().getName());
assertEquals("foo", encoder.getQpackContext().get(QpackContext.STATIC_TABLE.length).getHttpField().getName());
assertMetaDataSame(original0, decoded0);
@ -192,17 +192,17 @@ public class HpackTest
MetaData decoded1 = decoder.decode(buffer);
assertMetaDataSame(original1, decoded1);
assertEquals(2, encoder.getHpackContext().size());
assertEquals(2, decoder.getHpackContext().size());
assertEquals("x", encoder.getHpackContext().get(HpackContext.STATIC_TABLE.length).getHttpField().getName());
assertEquals("foo", encoder.getHpackContext().get(HpackContext.STATIC_TABLE.length + 1).getHttpField().getName());
assertEquals(2, encoder.getQpackContext().size());
assertEquals(2, decoder.getQpackContext().size());
assertEquals("x", encoder.getQpackContext().get(QpackContext.STATIC_TABLE.length).getHttpField().getName());
assertEquals("foo", encoder.getQpackContext().get(QpackContext.STATIC_TABLE.length + 1).getHttpField().getName());
}
@Test
public void testHopHeadersAreRemoved() throws Exception
{
HpackEncoder encoder = new HpackEncoder();
HpackDecoder decoder = new HpackDecoder(4096, 16384);
QpackEncoder encoder = new QpackEncoder();
QpackDecoder decoder = new QpackDecoder(4096, 16384);
HttpFields input = HttpFields.build()
.add(HttpHeader.ACCEPT, "*")
@ -228,8 +228,8 @@ public class HpackTest
@Test
public void testTETrailers() throws Exception
{
HpackEncoder encoder = new HpackEncoder();
HpackDecoder decoder = new HpackDecoder(4096, 16384);
QpackEncoder encoder = new QpackEncoder();
QpackDecoder decoder = new QpackDecoder(4096, 16384);
String teValue = "trailers";
String trailerValue = "Custom";
@ -253,8 +253,8 @@ public class HpackTest
@Test
public void testColonHeaders() throws Exception
{
HpackEncoder encoder = new HpackEncoder();
HpackDecoder decoder = new HpackDecoder(4096, 16384);
QpackEncoder encoder = new QpackEncoder();
QpackDecoder decoder = new QpackDecoder(4096, 16384);
HttpFields input = HttpFields.build()
.add(":status", "200")
@ -262,13 +262,13 @@ public class HpackTest
ByteBuffer buffer = BufferUtil.allocate(2048);
BufferUtil.clearToFill(buffer);
assertThrows(HpackException.StreamException.class, () -> encoder.encode(buffer, new MetaData(HttpVersion.HTTP_2, input)));
assertThrows(QpackException.StreamException.class, () -> encoder.encode(buffer, new MetaData(HttpVersion.HTTP_2, input)));
encoder.setValidateEncoding(false);
encoder.encode(buffer, new MetaData(HttpVersion.HTTP_2, input));
BufferUtil.flipToFlush(buffer, 0);
assertThrows(HpackException.StreamException.class, () -> decoder.decode(buffer));
assertThrows(QpackException.StreamException.class, () -> decoder.decode(buffer));
}
private void assertMetaDataResponseSame(MetaData.Response expected, MetaData.Response actual)

View File

@ -16,7 +16,7 @@
":method": "GET"
},
{
"user-agent": "hpack-test"
"user-agent": "qpack-test"
},
{
"cookie": "xxxxxxx1"
@ -41,7 +41,7 @@
":method": "GET"
},
{
"user-agent": "hpack-test"
"user-agent": "qpack-test"
},
{
"cookie": "xxxxxxx2"

View File

@ -1,3 +1,3 @@
# Jetty Logging using jetty-slf4j-impl
#org.eclipse.jetty.http2.LEVEL=DEBUG
#org.eclipse.jetty.http2.hpack.LEVEL=DEBUG
#org.eclipse.jetty.http3.LEVEL=DEBUG
#org.eclipse.jetty.http3.qpack.LEVEL=DEBUG