Merged branch 'master' into 'jetty-9.1'.
This commit is contained in:
commit
dcbc0d9a21
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue