Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x

This commit is contained in:
Joakim Erdfelt 2020-09-17 02:43:18 -05:00
commit 75677b8a61
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
2 changed files with 16 additions and 7 deletions

View File

@ -496,6 +496,14 @@ public class Request implements HttpServletRequest
}
}
private boolean isContentEncodingSupported()
{
String contentEncoding = getHttpFields().get(HttpHeader.CONTENT_ENCODING);
if (contentEncoding == null)
return true;
return HttpHeaderValue.IDENTITY.is(contentEncoding);
}
private void extractContentParameters()
{
String contentType = getContentType();
@ -511,12 +519,11 @@ public class Request implements HttpServletRequest
if (MimeTypes.Type.FORM_ENCODED.is(baseType) &&
_channel.getHttpConfiguration().isFormEncodedMethod(getMethod()))
{
if (_metaData != null)
if (_metaData != null && !isContentEncodingSupported())
{
String contentEncoding = getHttpFields().get(HttpHeader.CONTENT_ENCODING);
if (contentEncoding != null && !HttpHeaderValue.IDENTITY.is(contentEncoding))
throw new BadMessageException(HttpStatus.NOT_IMPLEMENTED_501, "Unsupported Content-Encoding");
throw new BadMessageException(HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, "Unsupported Content-Encoding");
}
extractFormParameters(_contentParameters);
}
else if (MimeTypes.Type.MULTIPART_FORM_DATA.is(baseType) &&
@ -525,8 +532,10 @@ public class Request implements HttpServletRequest
{
try
{
if (_metaData != null && getHttpFields().contains(HttpHeader.CONTENT_ENCODING))
throw new BadMessageException(HttpStatus.NOT_IMPLEMENTED_501, "Unsupported Content-Encoding");
if (_metaData != null && !isContentEncodingSupported())
{
throw new BadMessageException(HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, "Unsupported Content-Encoding");
}
getParts(_contentParameters);
}
catch (IOException e)

View File

@ -572,7 +572,7 @@ public class RequestTest
}
catch (BadMessageException e)
{
return e.getCode() == 501;
return e.getCode() == 415;
}
}
};