Update from review
reformat Use ByteBuffer API Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
905bf82f80
commit
afa987ac64
|
@ -523,9 +523,6 @@ public class Huffman
|
||||||
long current = 0;
|
long current = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
byte[] array = buffer.array();
|
|
||||||
int p = buffer.arrayOffset() + buffer.position();
|
|
||||||
|
|
||||||
int len = b.length;
|
int len = b.length;
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
|
@ -540,7 +537,7 @@ public class Huffman
|
||||||
while (n >= 8)
|
while (n >= 8)
|
||||||
{
|
{
|
||||||
n -= 8;
|
n -= 8;
|
||||||
array[p++] = (byte)(current >> n);
|
buffer.put((byte)(current >> n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,9 +545,7 @@ public class Huffman
|
||||||
{
|
{
|
||||||
current <<= (8 - n);
|
current <<= (8 - n);
|
||||||
current |= (0xFF >>> n);
|
current |= (0xFF >>> n);
|
||||||
array[p++] = (byte)current;
|
buffer.put((byte)(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.position(p - buffer.arrayOffset());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,27 +135,26 @@ public class HpackTest
|
||||||
assertThat(e.getMessage(), containsString("Header too large"));
|
assertThat(e.getMessage(), containsString("Header too large"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void encodeDecodeNonAscii() throws Exception
|
public void encodeDecodeNonAscii() throws Exception
|
||||||
{
|
{
|
||||||
HpackEncoder encoder = new HpackEncoder();
|
HpackEncoder encoder = new HpackEncoder();
|
||||||
HpackDecoder decoder = new HpackDecoder(4096,8192);
|
HpackDecoder decoder = new HpackDecoder(4096, 8192);
|
||||||
ByteBuffer buffer = BufferUtil.allocate(16*1024);
|
ByteBuffer buffer = BufferUtil.allocate(16 * 1024);
|
||||||
|
|
||||||
HttpFields fields0 = new HttpFields();
|
HttpFields fields0 = new HttpFields();
|
||||||
fields0.add("Cookie","[\uD842\uDF9F]");
|
fields0.add("Cookie", "[\uD842\uDF9F]");
|
||||||
fields0.add("custom-key","[\uD842\uDF9F]");
|
fields0.add("custom-key", "[\uD842\uDF9F]");
|
||||||
Response original0 = new MetaData.Response(HttpVersion.HTTP_2,200,fields0);
|
Response original0 = new MetaData.Response(HttpVersion.HTTP_2, 200, fields0);
|
||||||
|
|
||||||
BufferUtil.clearToFill(buffer);
|
BufferUtil.clearToFill(buffer);
|
||||||
encoder.encode(buffer,original0);
|
encoder.encode(buffer, original0);
|
||||||
BufferUtil.flipToFlush(buffer,0);
|
BufferUtil.flipToFlush(buffer, 0);
|
||||||
Response decoded0 = (Response)decoder.decode(buffer);
|
Response decoded0 = (Response)decoder.decode(buffer);
|
||||||
|
|
||||||
assertMetadataSame(original0,decoded0);
|
assertMetadataSame(original0, decoded0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void evictReferencedFieldTest() throws Exception
|
public void evictReferencedFieldTest() throws Exception
|
||||||
|
|
Loading…
Reference in New Issue