use HttpStatus for 413 and 500 codes in SizeLimitHandler
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
be83eb94ad
commit
67404f96ce
|
@ -20,6 +20,7 @@ import org.eclipse.jetty.http.HttpException;
|
|||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.io.Content;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
|
@ -62,7 +63,7 @@ public class SizeLimitHandler extends Handler.Wrapper
|
|||
if (_requestLimit >= 0 && contentLength > _requestLimit)
|
||||
{
|
||||
String s = "Request body is too large: " + contentLength + ">" + _requestLimit;
|
||||
Response.writeError(request, response, callback, 413, s);
|
||||
Response.writeError(request, response, callback, HttpStatus.PAYLOAD_TOO_LARGE_413, s);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ public class SizeLimitHandler extends Handler.Wrapper
|
|||
{
|
||||
long contentLength = field.getLongValue();
|
||||
if (_responseLimit >= 0 && contentLength > _responseLimit)
|
||||
throw new HttpException.RuntimeException(500, "Response body is too large: " + contentLength + ">" + _responseLimit);
|
||||
throw new HttpException.RuntimeException(HttpStatus.INTERNAL_SERVER_ERROR_500, "Response body is too large: " + contentLength + ">" + _responseLimit);
|
||||
}
|
||||
return super.onAddField(field);
|
||||
}
|
||||
|
@ -109,7 +110,7 @@ public class SizeLimitHandler extends Handler.Wrapper
|
|||
_read += content.remaining();
|
||||
if (_requestLimit >= 0 && _read > _requestLimit)
|
||||
{
|
||||
BadMessageException e = new BadMessageException(413, "Request body is too large: " + _read + ">" + _requestLimit);
|
||||
BadMessageException e = new BadMessageException(HttpStatus.PAYLOAD_TOO_LARGE_413, "Request body is too large: " + _read + ">" + _requestLimit);
|
||||
request.fail(e);
|
||||
return null;
|
||||
}
|
||||
|
@ -126,7 +127,7 @@ public class SizeLimitHandler extends Handler.Wrapper
|
|||
{
|
||||
if (_responseLimit >= 0 && (_written + content.remaining()) > _responseLimit)
|
||||
{
|
||||
callback.failed(new HttpException.RuntimeException(500, "Response body is too large: " +
|
||||
callback.failed(new HttpException.RuntimeException(HttpStatus.INTERNAL_SERVER_ERROR_500, "Response body is too large: " +
|
||||
_written + content.remaining() + ">" + _responseLimit));
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue