Issue #9554 - changes from review
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
6ad6dea1a2
commit
2d935efe4d
|
@ -257,10 +257,9 @@ public class HttpTokens
|
|||
return ' ';
|
||||
|
||||
default:
|
||||
if (c >= 256 || c < ' ')
|
||||
if (isIllegalFieldVchar(c))
|
||||
return '?';
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ package org.eclipse.jetty.http;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class MetaData implements Iterable<HttpField>
|
||||
|
@ -101,28 +100,6 @@ public class MetaData implements Iterable<HttpField>
|
|||
return _fields.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(_httpVersion, _contentLength, _fields, _trailerSupplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof MetaData))
|
||||
return false;
|
||||
|
||||
MetaData other = (MetaData)obj;
|
||||
if (!Objects.equals(_httpVersion, other._httpVersion))
|
||||
return false;
|
||||
if (!Objects.equals(_contentLength, other._contentLength))
|
||||
return false;
|
||||
if (!Objects.equals(_fields, other._fields))
|
||||
return false;
|
||||
return _trailerSupplier == null && other._trailerSupplier == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ import static org.eclipse.jetty.http.compression.Huffman.rowsym;
|
|||
*/
|
||||
public class HuffmanDecoder
|
||||
{
|
||||
private final CharsetStringBuilder.Iso8859StringBuilder _builder = new CharsetStringBuilder.Iso8859StringBuilder();
|
||||
private final CharsetStringBuilder.Iso88591StringBuilder _builder = new CharsetStringBuilder.Iso88591StringBuilder();
|
||||
private int _length = 0;
|
||||
private int _count = 0;
|
||||
private int _node = 0;
|
||||
|
|
|
@ -69,7 +69,7 @@ public class HuffmanEncoder
|
|||
* @param s the string to encode in lowercase.
|
||||
* @return the number of octets needed to encode the string, or -1 if it cannot be encoded.
|
||||
*/
|
||||
public static int octetsNeededLowercase(String s)
|
||||
public static int octetsNeededLowerCase(String s)
|
||||
{
|
||||
return octetsNeeded(LCCODES, s);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class HuffmanEncoder
|
|||
* @param buffer the buffer to encode into in lowercase.
|
||||
* @param s the string to encode.
|
||||
*/
|
||||
public static void encodeLowercase(ByteBuffer buffer, String s)
|
||||
public static void encodeLowerCase(ByteBuffer buffer, String s)
|
||||
{
|
||||
encode(LCCODES, buffer, s);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class NBitStringParser
|
|||
{
|
||||
private final NBitIntegerParser _integerParser;
|
||||
private final HuffmanDecoder _huffmanBuilder;
|
||||
private final CharsetStringBuilder.Iso8859StringBuilder _builder;
|
||||
private final CharsetStringBuilder.Iso88591StringBuilder _builder;
|
||||
private boolean _huffman;
|
||||
private int _count;
|
||||
private int _length;
|
||||
|
@ -50,7 +50,7 @@ public class NBitStringParser
|
|||
{
|
||||
_integerParser = new NBitIntegerParser();
|
||||
_huffmanBuilder = new HuffmanDecoder();
|
||||
_builder = new CharsetStringBuilder.Iso8859StringBuilder();
|
||||
_builder = new CharsetStringBuilder.Iso88591StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -173,7 +173,7 @@ public class HpackDecoder
|
|||
if (huffmanName)
|
||||
name = huffmanDecode(buffer, length);
|
||||
else
|
||||
name = toISO8859String(buffer, length);
|
||||
name = toISO88591String(buffer, length);
|
||||
check:
|
||||
for (int i = name.length(); i-- > 0; )
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ public class HpackDecoder
|
|||
if (huffmanValue)
|
||||
value = huffmanDecode(buffer, length);
|
||||
else
|
||||
value = toISO8859String(buffer, length);
|
||||
value = toISO88591String(buffer, length);
|
||||
|
||||
// Make the new field
|
||||
HttpField field;
|
||||
|
@ -321,12 +321,12 @@ public class HpackDecoder
|
|||
}
|
||||
}
|
||||
|
||||
public static String toISO8859String(ByteBuffer buffer, int length)
|
||||
public static String toISO88591String(ByteBuffer buffer, int length)
|
||||
{
|
||||
CharsetStringBuilder.Iso8859StringBuilder builder = new CharsetStringBuilder.Iso8859StringBuilder();
|
||||
CharsetStringBuilder.Iso88591StringBuilder builder = new CharsetStringBuilder.Iso88591StringBuilder();
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
builder.append((char)(0x7F & buffer.get()));
|
||||
builder.append(HttpTokens.sanitizeFieldVchar((char)buffer.get()));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
|
|
@ -441,8 +441,8 @@ public class HpackEncoder
|
|||
// leave name index bits as 0
|
||||
// Encode the name always with lowercase huffman
|
||||
buffer.put((byte)0x80);
|
||||
NBitIntegerEncoder.encode(buffer, 7, HuffmanEncoder.octetsNeededLowercase(name));
|
||||
HuffmanEncoder.encodeLowercase(buffer, name);
|
||||
NBitIntegerEncoder.encode(buffer, 7, HuffmanEncoder.octetsNeededLowerCase(name));
|
||||
HuffmanEncoder.encodeLowerCase(buffer, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -73,8 +73,8 @@ public class HpackFieldPreEncoder implements HttpFieldPreEncoder
|
|||
else
|
||||
{
|
||||
buffer.put((byte)0x80);
|
||||
NBitIntegerEncoder.encode(buffer, 7, HuffmanEncoder.octetsNeededLowercase(name));
|
||||
HuffmanEncoder.encodeLowercase(buffer, name);
|
||||
NBitIntegerEncoder.encode(buffer, 7, HuffmanEncoder.octetsNeededLowerCase(name));
|
||||
HuffmanEncoder.encodeLowerCase(buffer, name);
|
||||
}
|
||||
|
||||
HpackEncoder.encodeValue(buffer, huffman, value);
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.jetty.http3.qpack;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
|
@ -127,4 +128,15 @@ public class QpackTestUtil
|
|||
{
|
||||
return new MetaData(HttpVersion.HTTP_3, fields);
|
||||
}
|
||||
|
||||
public static boolean compareMetaData(MetaData m1, MetaData m2)
|
||||
{
|
||||
if (!Objects.equals(m1.getHttpVersion(), m2.getHttpVersion()))
|
||||
return false;
|
||||
if (!Objects.equals(m1.getContentLength(), m2.getContentLength()))
|
||||
return false;
|
||||
if (!Objects.equals(m1.getFields(), m2.getFields()))
|
||||
return false;
|
||||
return m1.getTrailerSupplier() == null && m2.getTrailerSupplier() == null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public interface CharsetStringBuilder
|
|||
{
|
||||
Objects.requireNonNull(charset);
|
||||
if (charset == StandardCharsets.ISO_8859_1)
|
||||
return new Iso8859StringBuilder();
|
||||
return new Iso88591StringBuilder();
|
||||
if (charset == StandardCharsets.US_ASCII)
|
||||
return new UsAsciiStringBuilder();
|
||||
|
||||
|
@ -87,7 +87,7 @@ public interface CharsetStringBuilder
|
|||
return new DecoderStringBuilder(charset.newDecoder());
|
||||
}
|
||||
|
||||
class Iso8859StringBuilder implements CharsetStringBuilder
|
||||
class Iso88591StringBuilder implements CharsetStringBuilder
|
||||
{
|
||||
private final StringBuilder _builder = new StringBuilder();
|
||||
|
||||
|
@ -275,5 +275,3 @@ public interface CharsetStringBuilder
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue