Merge pull request #5286 from eclipse/jetty-9.4.x-5285-415-unsupported-media-type
Issue #5285 - Using Status code 415 Unsupported Media Type instead
This commit is contained in:
commit
c6ed603453
|
@ -497,6 +497,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();
|
||||
|
@ -512,12 +520,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) &&
|
||||
|
@ -526,8 +533,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)
|
||||
|
|
|
@ -613,7 +613,7 @@ public class RequestTest
|
|||
}
|
||||
catch (BadMessageException e)
|
||||
{
|
||||
return e.getCode() == 501;
|
||||
return e.getCode() == 415;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue