Merged branch 'master' into 'jetty-9.1'.

This commit is contained in:
Simone Bordet 2013-10-22 13:34:06 +02:00
commit dcbc0d9a21
1 changed files with 25 additions and 17 deletions

View File

@ -65,8 +65,11 @@ public abstract class BufferingResponseListener extends Listener.Adapter
HttpFields headers = response.getHeaders();
long length = headers.getLongField(HttpHeader.CONTENT_LENGTH.asString());
if (length > maxLength)
{
response.abort(new IllegalArgumentException("Buffering capacity exceeded"));
}
else
{
String contentType = headers.get(HttpHeader.CONTENT_TYPE);
if (contentType != null)
{
@ -83,19 +86,24 @@ public abstract class BufferingResponseListener extends Listener.Adapter
}
}
}
}
@Override
public void onContent(Response response, ByteBuffer content)
{
long newLength = buffer.length + content.remaining();
if (newLength > maxLength)
{
response.abort(new IllegalArgumentException("Buffering capacity exceeded"));
}
else
{
byte[] newBuffer = new byte[(int)newLength];
System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);
content.get(newBuffer, buffer.length, content.remaining());
buffer = newBuffer;
}
}
@Override
public abstract void onComplete(Result result);