review fixes

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2018-07-12 11:50:53 +02:00
parent 1e703e8368
commit a9819ebb01
4 changed files with 25 additions and 26 deletions

View File

@ -73,7 +73,7 @@ public class HpackDecoder
// If the buffer is big, don't even think about decoding it
if (buffer.remaining()>_builder.getMaxSize())
throw new HpackException.Session("431 Request Header Fields too large",6);
throw new HpackException.SessionException("431 Request Header Fields too large");
while(buffer.hasRemaining())
{
@ -92,7 +92,7 @@ public class HpackDecoder
int index = NBitInteger.decode(buffer,7);
Entry entry=_context.get(index);
if (entry==null)
throw new HpackException.Session("Unknown index %d",index);
throw new HpackException.SessionException("Unknown index %d",index);
if (entry.isStatic())
{

View File

@ -27,26 +27,25 @@ public abstract class HpackException extends RuntimeException
super(String.format(messageFormat, args));
}
public static class Stream extends HpackException
public static class StreamException extends HpackException
{
Stream(String messageFormat, Object... args)
StreamException(String messageFormat, Object... args)
{
super(messageFormat,args);
}
}
public static class Session extends HpackException
public static class SessionException extends HpackException
{
Session(String messageFormat, Object... args)
SessionException(String messageFormat, Object... args)
{
super(messageFormat,args);
}
}
public static class Compression extends Session
public static class CompressionException extends SessionException
{
public Compression(String messageFormat, Object... args)
public CompressionException(String messageFormat, Object... args)
{
super(messageFormat,args);
}

View File

@ -27,7 +27,7 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http2.hpack.HpackException.Session;
import org.eclipse.jetty.http2.hpack.HpackException.SessionException;
public class MetaDataBuilder
{
@ -40,7 +40,7 @@ public class MetaDataBuilder
private String _path;
private long _contentLength=Long.MIN_VALUE;
private HttpFields _fields = new HttpFields(10);
private HpackException.Stream _streamException;
private HpackException.StreamException _streamException;
private boolean _request;
private boolean _response;
@ -68,7 +68,7 @@ public class MetaDataBuilder
return _size;
}
public void emit(HttpField field) throws HpackException.Session
public void emit(HttpField field) throws HpackException.SessionException
{
HttpHeader header = field.getHeader();
String name = field.getName();
@ -76,7 +76,7 @@ public class MetaDataBuilder
int field_size = name.length() + (value == null ? 0 : value.length());
_size+=field_size+32;
if (_size>_maxSize)
throw new HpackException.Session("Header Size %d > %d",_size,_maxSize);
throw new HpackException.SessionException("Header Size %d > %d",_size,_maxSize);
if (field instanceof StaticTableHttpField)
{
@ -162,10 +162,10 @@ public class MetaDataBuilder
break;
case TE:
if ("trailors".equalsIgnoreCase(value))
if ("trailers".equalsIgnoreCase(value))
_fields.add(field);
else
streamException("unsupported TE value %s", value);
streamException("Unsupported TE value %s", value);
break;
case CONNECTION:
@ -175,7 +175,7 @@ public class MetaDataBuilder
default:
if (name.charAt(0)==':')
streamException("Unknown psuodo header %s", name);
streamException("Unknown pseudo header %s", name);
else
_fields.add(field);
break;
@ -184,7 +184,7 @@ public class MetaDataBuilder
else
{
if (name.charAt(0)==':')
streamException("Unknown psuedo header %s",name);
streamException("Unknown pseudo header %s",name);
else
_fields.add(field);
}
@ -192,7 +192,7 @@ public class MetaDataBuilder
void streamException(String messageFormat, Object... args)
{
HpackException.Stream stream = new HpackException.Stream(messageFormat, args);
HpackException.StreamException stream = new HpackException.StreamException(messageFormat, args);
if (_streamException==null)
_streamException = stream;
else
@ -226,13 +226,13 @@ public class MetaDataBuilder
}
public MetaData build() throws HpackException.Stream
public MetaData build() throws HpackException.StreamException
{
if (_streamException!=null)
throw _streamException;
if (_request && _response)
throw new HpackException.Stream("Request and Response headers");
throw new HpackException.StreamException("Request and Response headers");
try
{
@ -266,14 +266,14 @@ public class MetaDataBuilder
* Check that the max size will not be exceeded.
* @param length the length
* @param huffman the huffman name
* @throws Session
* @throws SessionException
*/
public void checkSize(int length, boolean huffman) throws Session
public void checkSize(int length, boolean huffman) throws SessionException
{
// Apply a huffman fudge factor
if (huffman)
length=(length*4)/3;
if ((_size+length)>_maxSize)
throw new HpackException.Session("Header too large %d > %d", _size+length, _maxSize);
throw new HpackException.SessionException("Header too large %d > %d", _size+length, _maxSize);
}
}

View File

@ -224,7 +224,7 @@ public class HpackDecoderTest
decoder.decode(buffer);
Assert.fail();
}
catch (HpackException.Session e)
catch (HpackException.SessionException e)
{
assertThat(e.getMessage(),Matchers.startsWith("Unknown index"));
}